发布

  • amp: fix missing tool output in UI (toolUseID/run.result) (#122)

    frostbyte_neo 发布于 2026-03-10 04:11:52 +00:00 | 983 次提交 在此版本后已推送到 main

    AMP has tool results that don't use the usual tool_use_id + content
    fields. Instead, you'll see toolUseID and the payload under
    run.result. The shared extractor doesn't recognize that, so those
    results were being skipped and tool calls showed up with empty output in
    the UI.

    Example: AMP built-in librarian

    {"type":"tool_use","id":"toolu_vrtx_01Mxhky7udxH85j2LkLiW33f","name":"librarian"}
    

    Previously dropped result:

    {
      "type": "tool_result",
      "toolUseID": "toolu_vrtx_01Mxhky7udxH85j2LkLiW33f",
      "run": {
        "status": "done",
        "result": "Here is a complete, code-level breakdown..."
      }
    }
    

    Changes

    • internal/parser/amp.go: parse AMP-style tool results (toolUseID +
      run.result) and normalize the output into displayable text; keep the
      shared extractor untouched and append AMP results.
    • internal/parser/amp_test.go: add unit + integration coverage for the
      AMP result shapes (string/dict/list/null + error/cancelled).
    • internal/sync/engine_test.go: add a regression that checks the parse
      -> pair -> decode path so ResultContent is actually populated.

    Empty successful output is still treated as "nothing to show".
    Errors/cancelled runs get a small placeholder so you can tell what
    happened.

    Validation

    go test ./internal/parser -run 'TestSerializeAmpResult|TestExtractAmpToolResults|TestParseAmpSession_AmpToolResultSchema|TestParseAmpSession_AmpToolResultDict|TestParseAmpSession_ToolUseAndThinking'
    go test ./internal/sync -run 'TestPairToolResultsContent'
    

    Co-authored-by: Claude Sonnet 4.6 noreply@anthropic.com

    下载附件