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: harden background questions, session prompts, and ACP execution (#170)
## Related Issue
No issue — internal bug fixes found while auditing the agent engine and
the ACP bridge.
## Problem
Four defects, all reachable from normal use:
1. **The system prompt changed underneath a running session.**
`ProfileService` rebuilt it on every `AGENTS.md` change, so editing
instructions mid-session silently swapped the prompt the model had
already been reasoning against, and invalidated the prompt cache.
2. **`AskUserQuestion` offered background tasks that could not exist.**
The tool advertised `background: true` in its schema and description
regardless of whether `TaskList`, `TaskOutput`, and `TaskStop` were
active. Choosing it produced a task nothing could list, read, or stop.
3. **ACP sessions died on clients without a terminal.**
`AcpTerminalRunner` threw when the client declared no terminal
capability, so a whole class of ACP clients could not run a single shell
command.
4. **ACP rejected typeless stdio MCP servers, and a reloaded ACP session
could not re-bind its runtime.** A failed teardown left the staged entry
in the runtime list forever, so the retry hit a stale slot.
## What changed
1. Dropped the `instructions.onDidChange` re-render.
`refreshSystemPrompt` still reads instructions, so an explicitly
requested refresh works — only the implicit rebuild is gone.
2. `AskUserQuestion` now derives its schema *and* its description from
the live tool policy, in both engines. The v1 path passes the
**predicate**, not a resolved boolean, so a policy change later in the
session is picked up rather than frozen at construction.
3. `AcpTerminalRunner` falls back to the local process service instead
of throwing. `IHostProcessService` is threaded through the session
runtime, the workspace attachment, the provider factory, and `start.ts`.
4. A typeless ACP MCP server maps to a stdio server. `runtimeUnitHost`
prunes the staged entry in a `finally`, so a throwing teardown cannot
strand it.
## 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.
## Verification
`pnpm run typecheck` 0 · `pnpm run lint` 0 errors · agent-core 54/54 ·
agent-core-v2 and acp suites green.
The `AskUserQuestion` fix is mutation-proven: replacing the predicate
with a resolved boolean turns `rechecks AskUserQuestion background mode
after the task policy changes` red (1 failed / 20 passed), and restoring
it returns 21/21. That distinction is the entire point of the change, so
it is the one guarded by a test that provably fails without it.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- ACP sessions can run supported shell commands through terminal access
or locally when terminal access is unavailable.
- Stdio-based MCP servers are supported in new and reloaded sessions.
- Runtime connections recover correctly after session reloads.
- **Bug Fixes**
- Background questions are offered only when task controls are
available.
- Session system prompts remain stable after `AGENTS.md` changes.
- Runtime cleanup supports reliable re-registration after teardown
failures.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Run a command locally when an ACP client provides no terminal or the command is not a shell, accept stdio MCP servers in ACP sessions, and let a reloaded ACP session bind its runtime again.
0 commit comments