Skip to content

BUG: amicode_ask answer flips develop/research sessions to plan mode (agent omitted in promptAsync) #1206

Description

@jeonghun-jj-lee

Important

Problem: The deprecated amicode_ask tool ends the assistant turn, and the user's button-click answer arrives as a new promptAsync call with no agent field. The server's createUserMessage falls back to agents.defaultInfo() — the global default_agent: "plan" — silently flipping an active develop/research session into plan mode mid-campaign. The model then receives the plan-mode gag and goes read-only.

Approach: Two-layer fix: (1) server hardening — createUserMessage falls back to the session's tracked current agent before the global default, so any caller that omits agent continues the session's mode instead of resetting it; (2) client fix — thread the current agent into the two promptAsync calls in message-timeline.tsx (onAsk and widget-prompt) that omit it.

Scope: overlay engine (session/prompt.ts) + app (message-timeline.tsx). No interview flow, no score, no extension host changes.

Assumptions: amicode_ask remains registered (deprecated but not removed); the native question tool is unaffected (it's an in-turn tool call, never flips the agent). Fresh sessions are unaffected — current.agent is already plan/undefined, so the fallback chain is identical to today.

Evidence

Confirmed from live session data (ses_f5d21a3ceffekcFtdQib23wFYf, post-fix #1153):

# role agent event
84 assistant develop calls amicode_ask
85 assistant develop empty step-finish (turn ended)
86 user plan button answer — no agent in promptAsync
87 assistant plan "I'm now in plan mode" — refuses to act

Normal typed messages in the same session carry develop correctly. Only the amicode_ask answer flips.

The #1153 reminders fix (the plan-to-executing un-gag) is deployed and correct — it addresses a different sub-problem (the reminder text after a legitimate mode switch). This bug is upstream of that: the mode switch itself is illegitimate.

Acceptance Criteria

  • A promptAsync call with no agent on a session whose current agent is develop produces a user message stamped develop (not plan)
  • The two promptAsync calls in message-timeline.tsx (onAsk at ~2558, widget-prompt at ~2534) pass the session's current agent
  • Fresh sessions (no prior turns) still default to plan as before
  • Regression test covers the omit-agent-continues-session-mode case

Key Decisions

  • Server fallback, not caller enumeration: createUserMessage checks current.agent before defaultInfo() — structurally covers every present and future omit-agent caller, matching the #1153 "no mode-name enumeration" philosophy.
  • Client belt-and-suspenders: the message-timeline.tsx calls also pass the agent explicitly, so even if the server fallback were removed, these callers wouldn't regress.

Constraints & Invariants

  • The native question tool is an in-turn tool call and is unaffected by this change.
  • amicode_ask is deprecated; this fix is a bridge until it's fully retired.

Prior Art

  • #1153 — the reminders fix that broadened the plan-to-executing un-gag to all primary agents (correct, deployed, addresses a different sub-problem).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions