AI工程SynapseB类

Task Topology Design for Stateful Agent Pipelines

TL;DR

  • Synapse replaces Claude Code single-agent loops with explicit task topology orchestration
  • Context loss in multi-turn iterations exposes a core self-developed Agent framework trap
  • State snapshots plus stage gating resolve over 80% of hallucination issues
  • Claude Code requires manual state management when running complex multi-step scenarios
  • Synapse checkpoint mechanism enables task rollback without re-executing previous steps

The Problem

We built an automated code review Agent using Claude Code in Q4 last year. The initial version took three weeks and delivered zero P0 bugs. But when business requested branch-dimension report aggregation, things broke. Claude Code started skipping files in diff summaries and drifting in report formatting by round four. In one week, we logged 17 issues—nine directly caused by Agent state inconsistency.

We first blamed the prompts. After two days of tweaking system instructions and adding three few-shot examples, context jumping still occurred after round three, dropping only from 78% to 61% probability. But the real issue was structural: Claude Code operates at the session level while our code review workflow is pipeline-level. A review task spans five steps—pull diff, filter test files, generate summary, format report, send notification—where each step’s input depends on the previous step’s output. We were using Claude Code to process a state-dependent pipeline while treating it as a question-answering tool.

The context jumping root cause was not the model forgetting—it was that we failed to build a memory mechanism for it.

How We Solved It

We inverted the relationship. Synapse handles task topology while Claude Code focuses on node-level execution. We designed a task_state snapshot mechanism in Synapse. After each pipeline node completes, it writes key state to a shared JSON context. This allows the next step to receive structured input derived from the previous step’s output rather than relying on implicit conversation history.

The checkpoint mechanism captures intermediate results with hashes and timestamps, enabling rollback without re-executing completed steps.

Key Takeaways

  • If you connect Claude Code to multi-step workflows, implement explicit state passing between steps rather than relying on conversational context
  • If you observe inconsistent behavior after round three, suspect pipeline-level context fragmentation rather than prompt inadequacy
  • If your workflow has interdependent stages, treat Claude Code as a specialized executor and route topology through a separate orchestration layer
  • If you need reliable retry logic, add checkpoint snapshots with output hashes at each pipeline stage
  • If you find context jumping, verify whether your system treats session-based tools as pipeline components

Read the Full Article (Chinese)

This is an abstract. The full technical walkthrough with implementation details is available in the original Chinese article.