Skip to content

fix(session): interview must ask via the question tool, not prose - #37

Merged
Rchari1 merged 1 commit into
local/amicodefrom
rchari/interview-question-tool-guard
Jul 20, 2026
Merged

Rchari1 merged 1 commit into
local/amicodefrom
rchari/interview-question-tool-guard

Conversation

@Rchari1

@Rchari1 Rchari1 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Problem

The Amico pulse-designer interview asks each question via the native question tool, which renders the clickable answer card. Models intermittently drift and ask in plain prose instead — e.g.:

"What's your qubit frequency ω (GHz) and anharmonicity δ (GHz), and do you want 3 or 4 levels?"

That renders no card, so the user has nothing to click and the interview stalls. Reported repeatedly. Prompt hardening in AGENTS.md alone did not hold — LLM tool-use adherence is probabilistic — so this enforces the contract in the turn loop.

Fix

In the session prompt loop, when a turn is about to exit (assistant finished, no tool calls) and:

  • an Amico interview is active (the session has used any amicode_* tool), and
  • this turn made no question tool call, and
  • the assistant's final text ends with ? (a question to the user),

…inject a synthetic system nudge ("re-ask via the question tool") and continue the loop instead of exiting — forcing the model to re-emit the question as a card.

Idempotent: an in-memory Set of nudged assistant-message IDs fires the nudge at most once per message (the Assistant info schema has no metadata field to persist a flag on), so a stubborn turn cannot loop forever — after one nudge it exits normally.

Scope: only fires inside an active amicode interview. Ordinary agent turns that happen to end in a question (e.g. a build agent asking for clarification) are unaffected — they haven't used amicode_* tools.

Testing

  • tsgo --noEmit: clean
  • Built the darwin-arm64 binary, swapped into the amicode dev host, verified the interview re-asks via the tool (card renders) after a prose drift.

Follow-up

Once merged, cut a fork release so the amicode extension's vendored binary (opencode.lock.json) can bump to it — the fix ships to users via that pin, not this branch directly.

The Amico pulse-designer interview asks each question via the native `question`
tool, which renders the clickable answer card. Models intermittently drift and
ask in PLAIN PROSE instead ("What's your qubit frequency and do you want 3 or 4
levels?"), which renders no card — the user has nothing to click and the
interview stalls. Prompt hardening in AGENTS.md alone did not hold (LLM
tool-use adherence is probabilistic), so this enforces it in the turn loop.

Guard in the session prompt loop: when a turn is about to exit (assistant
finished, no tool calls) AND
  - an Amico interview is active (the session has used any `amicode_*` tool), AND
  - this turn made NO `question` tool call, AND
  - the assistant's final text ends with "?" (a question to the user),
inject a synthetic system nudge ("re-ask via the question tool") and continue
the loop instead of exiting, forcing the model to re-emit the question as a
card. Idempotent: an in-memory Set of nudged assistant-message IDs fires the
nudge at most once per message (the Assistant info schema has no metadata field
to persist a flag on), so a stubborn turn cannot loop forever — after one nudge
it exits normally.

Scope: only fires inside an active amicode interview; ordinary agent turns that
happen to end in a question (e.g. a build agent asking for clarification) are
unaffected because they haven't used amicode_* tools.

typecheck (tsgo --noEmit): clean. Built the darwin-arm64 binary and verified
the interview re-asks via the tool in the local dev host.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Rchari1
Rchari1 merged commit b48529f into local/amicode Jul 20, 2026
0 of 4 checks passed
@Rchari1
Rchari1 deleted the rchari/interview-question-tool-guard branch July 20, 2026 12:18
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.

1 participant