Skip to content

fix: Guard stream-json parser against non-dict JSON lines (#151) - #152

Merged
vybe merged 1 commit into
mainfrom
feature/151-stream-json-non-dict-fix
Mar 21, 2026
Merged

fix: Guard stream-json parser against non-dict JSON lines (#151)#152
vybe merged 1 commit into
mainfrom
feature/151-stream-json-non-dict-fix

Conversation

@vybe

@vybe vybe commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Added isinstance(raw_msg, dict) guards in all 4 stream-json parsing locations in claude_code.py
  • Prevents AttributeError: 'str' object has no attribute 'get' when Claude Code emits JSON string literals
  • Previously this crashed the stdout loop, discarding all execution results (cost, session_id, response)

Changes

  • docker/base-image/agent_server/services/claude_code.py — 4 guard clauses (lines ~148, ~283, ~547, ~882)
  • docs/memory/changelog.md — New entry

Test Plan

  • Deploy agent with updated base image
  • Run a scheduled task that uses context: fork with a subagent
  • Verify execution completes successfully (no "Task returned empty response")
  • Verify non-dict JSON lines are silently skipped in logs

Fixes #151

Generated with Claude Code

json.loads() can return a string when Claude Code emits a JSON string
literal in stream-json mode. Calling .get() on a str raised
AttributeError, which killed the stdout loop and discarded all
execution results. Added isinstance(raw_msg, dict) checks in all
four parsing locations.

Fixes #151

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vybe
vybe merged commit 856253b into main Mar 21, 2026
vybe added a commit that referenced this pull request Jun 17, 2026
* ci(deps): Dependabot auto-merge for low-risk PRs + grouping (#1243)

Adds .github/workflows/dependabot-auto-merge.yml — zero-touch merge for
Dependabot semver patch/minor only (all majors held). Gates on build +
pytest in-workflow; a machine PAT (DEPENDABOT_AUTOMERGE_TOKEN, stored as a
Dependabot secret) supplies the required approval since GITHUB_TOKEN can't,
then --auto --squash (CodeQL still enforced by branch protection).

dependabot.yml: group github-actions bumps into one weekly PR; cover the
previously-uncovered /tests/git-sync npm dir (source of esbuild alert #152).

Refs #1243

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* ci(deps): scope main PR to dependabot.yml only — drop auto-merge workflow (review #1244)

Per dolho's review and the conscious decision on #1243: auto-merge is dev-only.
main must NOT carry zero-touch merge machinery (a security PR to main could
auto-publish trinity-cli to PyPI unattended). This PR now ships only the
dependabot.yml grouping + /tests/git-sync coverage, which must live on main
since Dependabot reads config from the default branch. The (dev-guarded)
workflow reaches main later via the normal release, inert for main PRs.

Refs #1243

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Eugene Vyborov <eugene@beingluminous.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

bug: Agent server stream-json parser crashes on non-dict JSON lines

1 participant