You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(agent-core-v2): keep background questions open past turn end (#308)
## Related Issue
No tracked issue — internal reconciliation pass. Stacked on #307; review
that one first (and #306 under it).
## Problem
A background `AskUserQuestion` (asked with `background: true`) was bound
to the asking turn: the moment the agent finished its turn, the question
was cancelled and the user never got to answer it. When a background
question *was* answered, the agent received only the path of a saved
output file, not the answer itself.
## What changed
- Detached question requests no longer carry the asking turn's id, and
turn-end cancellation leaves them pending; the question stays open until
the user answers or dismisses it.
- The answer is now delivered to the agent inline in the task
notification — bounded to 16 KB and XML-escaped inside an `<answer>`
block — instead of only a saved output path. Answered and dismissed
outcomes get distinct notification text, and the transcript projection
keeps background-question answers grouped with their turn.
- `docs/reference/tools.md` documents the `background` behaviour on
`AskUserQuestion`; two patch changesets included.
- `dist-web` manifest restaged in the same commit (`packages/transcript`
is a web build input; only `.web-bundle-manifest.json` changed).
Verification on this commit: full pre-push gate (597s, all checks
passed), agent-core-v2 suite green, typecheck 0, lint 0, leak-check A–G
PASS.
## Checklist
- [x] I have read the
[CONTRIBUTING](https://github.com/PyModel/pythinker-code/blob/main/CONTRIBUTING.md)
document.
- [ ] I have linked a related issue (external PRs: the issue must have a
maintainer's `/approve`).
- [x] I have added tests that prove my feature works.
- [x] Ran `gen-changesets` skill, or this PR needs no changeset.
- [x] Ran `gen-docs` skill, or this PR needs no doc update.
Copy file name to clipboardExpand all lines: docs/reference/tools.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,13 +95,13 @@ Collaboration tools handle inter-Agent coordination, user interaction, and Skill
95
95
96
96
**`AgentDynamicWorkflow`** launches subagents from a shared `prompt_template` and an `items` array, resumes existing subagents through `resume_agent_ids`, or combines both in one call. The template must contain the `{{item}}` placeholder; each item replaces that placeholder and launches one new subagent. Pass `subagent_type` to choose the profile used by every spawned subagent in the dynamic_workflow, or omit it to use `coder`. Pass `model` (available when [secondary-model routing](../configuration/config-files.md#subagent-model-pool) is enabled and a pool is configured — a `[secondary_model.models]` table or a lone `default_model`) to run item-spawned subagents on a pool alias or on the caller's own model (`"primary"`). Without it, item-spawned subagents bind the pool's `default_model`; without a configured pool, they inherit the caller's model. Resumed subagents keep their own model. Without `resume_agent_ids`, the tool requires at least 2 items; with `resume_agent_ids`, it can resume one or more existing subagents. The tool supports up to 128 total subagents, waits for all subagents to finish, and returns an aggregated report. Each subagent times out after 2 hours by default; configure the limit with [`[dynamic_workflow] timeout_ms`](../configuration/config-files.md#dynamic-workflow) in `config.toml` (`0` means no timeout) or the `PYTHINKER_CODE_AGENT_DYNAMIC_WORKFLOW_TIMEOUT_MS` environment variable. Print mode (`pythinker -p`) defaults to no timeout. A timed-out subagent is aborted and marked as failed in the aggregated report. In the TUI, foreground dynamicWorkflows show a live `Agent dynamic_workflow` progress panel above the input box. If a model response calls `AgentDynamicWorkflow`, that call must be the only tool call in the response; to run multiple dynamicWorkflows, call one `AgentDynamicWorkflow`, wait for its result, then call the next, or combine the work into one dynamic_workflow when a single template can cover it. In `manual` permission mode, `AgentDynamicWorkflow` calls outside active dynamic_workflow mode request approval unless a permission rule allows them; while dynamic_workflow mode is active, `AgentDynamicWorkflow` itself is auto-approved. Permission rules match `AgentDynamicWorkflow` by tool name only — argument patterns such as `AgentDynamicWorkflow(dynamic_workflow)` are not supported. By default the tool ramps up concurrency without an upper limit (5 subagents start immediately, then 1 more every 700 ms); set `[dynamic_workflow] max_concurrency` or `PYTHINKER_CODE_AGENT_DYNAMIC_WORKFLOW_MAX_CONCURRENCY` to a positive integer to cap how many subagents run at the same time across all execution phases. An invalid environment value makes the call fail fast.
97
97
98
-
**`AskUserQuestion`** asks the user a structured multiple-choice question — useful for disambiguation or option selection. The `questions` parameter accepts 1–4 questions; each question requires `question` (ending with `?`), `options` (2–4 choices, each with a `label` and `description`), and optional `header` (max 12 characters) and `multi_select` (defaults to false). An "Other" option is appended automatically. Setting `background` to true starts a background question task and returns a task ID immediately. When the host does not support interactive questioning, a failure message is returned and the Agent should ask the user directly in a text reply instead.
98
+
**`AskUserQuestion`** asks the user a structured multiple-choice question — useful for disambiguation or option selection. The `questions` parameter accepts 1–4 questions; each question requires `question` (ending with `?`), `options` (2–4 choices, each with a `label` and `description`), and optional `header` (max 12 characters) and `multi_select` (defaults to false). An "Other" option is appended automatically. Setting `background` to true starts a background question task and returns a task ID immediately; the question stays open after the turn ends, and the answer is delivered to the Agent as a notification once the user responds. When the host does not support interactive questioning, a failure message is returned and the Agent should ask the user directly in a text reply instead.
99
99
100
100
**`Skill`** allows the Agent to actively invoke a registered inline-type Skill. Accepts `skill` (the Skill name) and optional `args` (additional argument text). Only `type = "inline"` Skills can be called via this tool; Skills with `disableModelInvocation: true` are rejected. Maximum nesting depth is 3 levels. See [Agent Skills](../customization/skills.md) for details.
101
101
102
102
## Background Tasks
103
103
104
-
Background task tools manage tasks started via `Bash`, `Agent`, or `AskUserQuestion`. When a task reaches a terminal state, its status and saved output path are automatically delivered back to the Agent; use `TaskOutput` to check progress early, or `WaitFor` to wait for a result inside the current turn.
104
+
Background task tools manage tasks started via `Bash`, `Agent`, or `AskUserQuestion`. When a task reaches a terminal state, its status and saved output path (or, for questions, the answer itself) are automatically delivered back to the Agent; use `TaskOutput` to check progress early, or `WaitFor` to wait for a result inside the current turn.
0 commit comments