Skip to content

fix(acp-driver): send the user's task before the host preamble - #153

Open
Luna Qiu (lunaqiu) wants to merge 1 commit into
microsoft:mainfrom
lunaqiu:fix/acp-preamble-first-message
Open

fix(acp-driver): send the user's task before the host preamble#153
Luna Qiu (lunaqiu) wants to merge 1 commit into
microsoft:mainfrom
lunaqiu:fix/acp-preamble-first-message

Conversation

@lunaqiu

Copy link
Copy Markdown
Collaborator

Root cause

Every externally-bound Huabu thread (Copilot CLI / Claude Code / Codex over ACP) opens its session/new + first session/prompt with the host's static system preamble concatenated before the user's actual request, because ACP has no separate system-role channel — both land in the same first message.

External agents that title a session from the leading characters of that first message (Copilot CLI observed) therefore show the exact same uninformative title — "You are a helpful assistant collaborating with a user inside Huabu, an infinite visual Space. The user wor…" — for every externally-bound session, regardless of what the user actually asked. Confirmed by inspecting the agent's own Sessions picker in another tool (VS Code) and matching the truncated text verbatim against �pps/server/src/prompt/external-agent/system_prompt.md.

Fix

Swap the concatenation order in \handle.ts\ so the user's task leads and the host preamble trails (still delivered once, still fully read by the agent before it responds — only the ordering within the single first message changes). Updated the one test that asserted the old order.

Testing

  • \pnpm --filter @agenetes/acp-driver test\ — 51/51 passing
  • \pnpm --filter @agenetes/acp-driver build\ — clean

Scope

External-only (\�xternal/agenetes) subtree change; no Huabu-app-side files touched.

External ACP agents receive Huabu's one-shot system preamble and the
user's first prompt concatenated into a single session/prompt
message (ACP has no separate system-role channel). The preamble was
sent first, so every externally-bound Huabu session started with the
exact same static boilerplate text.

Several external agents (Copilot CLI observed) title a session from
the leading characters of that first message, so every session showed
an identical, uninformative title in the agent's own session list
(e.g. its VS Code picker) regardless of what the user actually asked.

Swap the order so the user's task leads and the preamble trails. The
agent still reads the whole message before responding either way, but
title heuristics now key off unique, per-session content.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Recovery fallback still prepends static history, and architecture documentation still specifies the old ordering.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Reorders ACP’s initial prompt so the user request precedes the host preamble, improving external session titles.

Changes:

  • Appends the initial preamble after user content.
  • Updates the recovery test’s expected block order.
File summaries
File Description
external/agenetes/packages/acp-driver/src/handle.ts Reorders ACP prompt blocks and serialized content.
external/agenetes/packages/acp-driver/src/recovery.test.ts Updates the ordering assertion.
Review details

Suppressed comments (1)

external/agenetes/packages/acp-driver/src/handle.ts:501

  • The current request still does not lead the first ACP prompt on history-fallback recovery: prepared prepends historyText at lines 515–520. When native resume is unavailable, the newly created external session will therefore be titled from the same static history header rather than the user's task, so this fix does not cover all newly opened ACP sessions. Keep lowered.blocks first when assembling a fallback prompt (while preserving the intended history and preamble semantics) and cover that ordering in the recovery test.
        ? `${lowered.serialized}\n\n${preamble}`
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +488 to +490
// The user's actual request leads, the host preamble trails. ACP has
// no separate system-role channel, so this one-shot preamble is just
// more text in the same first `session/prompt` message — but several
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants