#8753·multica

[Bug]: Cross-agent ping-pong causes excessive agent invocations, context growth, and token processing

Author: ragavendran-ramesh26Created Sep 23, 2026Updated Sep 30, 2026
Labelsbug

Deployment type

self-host

Area

Web app

What happened?

Summary

We are seeing very high token processing in Multica during multi-agent development workflows.

After investigating one internal issue in our Multica workspace, the main cause does not appear to be repository context being loaded upfront.

Instead, the high usage appears to come from a combination of:

  1. repeated agent-to-agent handoffs,
  2. full coding agents being invoked for simple coordination/status messages,
  3. long-lived Claude sessions being resumed repeatedly,
  4. historical tool outputs remaining in active context,
  5. large numbers of tool calls within individual agent runs,
  6. retries/failures causing additional agent invocations,
  7. possible cumulative usage accounting on resumed Claude sessions.

The result is what we are calling Agent Ping-Pong Churn.

Our internal task reference is CREA-77, but this is a private workspace issue and is not accessible publicly. All relevant reproduction details are included below.


Environment / workload

The issue involved a normal multi-agent software development workflow with agents similar to:

Developer Agent
Reviewer Agent
Product Owner Agent

The workflow included:

implementation
→ review
→ requested changes
→ developer fix
→ re-review
→ Product Owner acceptance

This is a normal workflow, but it resulted in a surprisingly large number of full terminal-agent executions.


Observed usage

For a single internal development issue:

Total processed tokens:     18,037,422

Cache-read tokens:          17,229,583
Uncached input tokens:         357,366
Cache-write tokens:            326,240
Output tokens:                 124,233

Percentage breakdown:

Cache reads:       ~95.5%
Fresh input:        ~2.0%
Cache writes:       ~1.8%
Output:             ~0.7%

Agent/task activity:

Terminal agent tasks created:        approximately 22–23
Tasks with usage reported:                     16

Two representative executions:

Product Owner Agent
-------------------
Tool calls:                  41
Cache-read tokens:      ~3.0 million


Senior Developer Agent
----------------------
Tool calls:                 106
Cache-read tokens:     ~3.06 million

The base Multica runtime/context supplied at startup was relatively small:

Runtime brief:             ~20.6 KB
Repository instructions:   ~7.6 KB

This initial context alone cannot explain approximately 18 million processed tokens.


Observed execution chain

The following is a sanitized representation of the workflow.

Developer Agent
│
│ Implements change
│ Commits/pushes code
│ Posts completion message
│
▼
Reviewer Agent
│
│ Wakes up
│ Loads/resumes issue context
│ Reads files/diffs
│ Performs review
│ Posts findings
│
▼
Developer Agent
│
│ Wakes up again
│ Resumes larger context
│ Reads review comments
│ Fixes findings
│ Runs tools/tests
│ Posts:
│ "Addressed review threads..."
│
▼
Reviewer Agent
│
│ Wakes up again
│ Resumes larger context
│ Re-reads/re-checks changes
│ Posts:
│ "Re-review complete"
│
▼
User requests Product Owner check
│
▼
Developer Agent
│
│ Wakes up again
│ despite no coding task being necessary
│
│ Runs a full LLM agent loop only to post something similar to:
│
│ "@Product Owner, please perform the requested acceptance check."
│
▼
Product Owner Agent
│
│ Wakes up
│ Resumes/loads large issue context
│ Performs many tool calls
│ Hits provider/session limit
│ Task fails
│
▼
System records failed delegation
│
▼
Developer Agent
│
│ Wakes up AGAIN
│ despite there being no code change required
│
│ Posts something similar to:
│
│ "I inspected the failed delegation.
│  It produced no Product Owner result."
│
▼
More issue activity

This is where the majority of the unnecessary execution appears to originate.


Problem 1 — Agent Ping-Pong Churn

The core problem is that agents can trigger other agents through comments/handoffs, and those resulting responses can trigger more agent executions.

Conceptually:

Developer
   ↓
Reviewer
   ↓
Developer
   ↓
Reviewer
   ↓
Product Owner
   ↓
Developer
   ↓
...

Each individual transition may be technically valid.

However, at the issue/workflow level, the sequence becomes an expensive conversational loop.

There appears to be no effective overall guard against:

Agent A
→ Agent B
→ Agent A
→ Agent B
→ Agent C
→ Agent A

continuing indefinitely.


Problem 2 — Full coding agents are used for coordination

A major source of unnecessary usage appears to be using heavyweight coding agents for actions that do not require reasoning or code execution.

Examples observed or implied by the workflow:

"Please ask the Product Owner."

"Review completed."

"Changes addressed."

"Assign this back to developer."

"Product Owner task failed."

"I checked the failed delegation."

"Please review again."

These operations should not normally require:

large model context
+
repository access
+
git access
+
50+ tools
+
full issue history
+
LLM reasoning loop

A workflow/orchestration service should be able to handle most of them deterministically.


Problem 3 — Communication is also used as execution control

At the moment, an agent-generated comment appears capable of acting both as:

1. human-readable communication

and

2. trigger for another autonomous agent execution

This creates a dangerous feedback loop.

For example:

Developer LLM generates:
"@Reviewer please review"

That text causes:

Reviewer LLM execution

The Reviewer then generates:

"@Developer please address these findings"

which causes:

Developer LLM execution

The conversation itself effectively becomes the workflow engine.

We believe these concerns should be separated:

Human-readable comment
           ≠
Workflow transition

Problem 4 — Context grows during long agent sessions

The second major multiplier is context growth.

A long-running agent performs operations such as:

issue lookup
repository search
file reads
git diff
git log
tests
terminal commands
issue comments
skill/resource lookup
additional file reads
additional searches
review output

Results from those tool calls remain part of the conversation.

The next model invocation therefore sees something like:

original instructions
+
issue history
+
previous assistant responses
+
previous tool results
+
new tool result

Then another tool executes:

everything above
+
another result

The active context continually increases.


Simplified context amplification example

For illustration:

Initial context:       25k tokens

Tool call 1:
context processed:     30k

Tool call 10:
context processed:     40k

Tool call 20:
context processed:     50k

Tool call 40:
context processed:     65k

Tool call 70:
context processed:     80k

Tool call 100:
context processed:     90k+

Even if most of this input is cached, it is still repeatedly processed and counted as cache-read usage.

This explains how a single run with approximately 100 tool calls can produce millions of cache-read tokens.


Problem 5 — A high cache-hit rate hides inefficient execution

In our example:

17.23 million / 18.04 million

processed tokens were cache reads.

That is approximately:

95.5%

The caching mechanism therefore appears to be working.

However:

A high cache-hit ratio does not mean the workflow itself is efficient.

It may instead mean that Multica is efficiently caching a very large and repeatedly processed conversation.

In other words:

Good cache efficiency
        +
Poor context lifecycle
        =
Large cached-token processing

Problem 6 — Session continuation increases context lifetime

Follow-up activity appears to resume the same issue/agent session.

Conceptually:

Issue X
│
└── Developer Agent
       │
       └── Claude session A
            │
            ├── implementation
            ├── resume
            ├── review response
            ├── resume
            ├── fix
            ├── resume
            ├── coordination
            ├── resume
            ├── failure handling
            └── ...

This means old information remains relevant to the provider context for a long period.

A better lifecycle might be:

Session A
   │
   ├── actual implementation work
   │
   ▼
Checkpoint
   │
   ▼
Fresh Session B
   │
   └── compact structured state only

Problem 7 — Tool history remains too large

Large tool outputs seem to contribute heavily to the active conversation.

Examples:

full source files
large git diffs
long test output
terminal logs
search results
issue comments
repository metadata

Instead of carrying all of this indefinitely, older data could be summarized or artifactized.

Example:

Current behavior:

git diff
→ thousands of lines inserted into conversation

Preferred:

git diff summary:

14 files changed
+643 / -201

Important files:
- service.py
- repository.py
- test_service.py

Full diff:
artifact://run/123/diff.txt

The model can explicitly request the full artifact later if required.


Problem 8 — Follow-up actions may unnecessarily rediscover context

A simple follow-up should not necessarily cause another full investigation.

Example:

Agent:
"Implementation is complete. Shall I request review?"

User:
"Yes."

Ideally this should result in:

workflow.request_review()

It should not result in another agent doing:

fetch issue
read comments
inspect repository
read branch
git status
git log
read files
analyze context
then request review

This type of repeated acquisition becomes particularly expensive when the existing context is already large.


Problem 9 — Failure events can create another execution loop

One observed sequence was:

Product Owner agent execution
        ↓
provider/session limit
        ↓
task fails
        ↓
failure recorded
        ↓
Developer agent wakes
        ↓
Developer explains the failure

The final Developer execution appears unnecessary.

The orchestration layer already knows:

agent = Product Owner
task = acceptance review
status = failed
reason = provider/session limit

It could directly record/display:

"Product Owner acceptance could not run because the provider limit was reached."

without invoking another coding agent.


Problem 10 — Possible cumulative Claude usage accounting issue

We also observed two failed/resumed executions reporting exactly the same processed-token value:

Run A:
1,331,726 processed tokens

Run B:
1,331,726 processed tokens

The second run produced only a very small amount of new visible output.

This raises a separate question about Claude usage accounting.

If the Claude session reports cumulative usage across a resumed session, Multica must ensure it records the incremental delta rather than counting the cumulative session total again.

Potential incorrect behavior:

Run 1 cumulative usage:
1,000,000

Run 2 cumulative usage:
1,250,000

Recorded usage:
1,000,000 + 1,250,000
= 2,250,000

Expected if values are cumulative:

Run 1:
1,000,000

Run 2 delta:
250,000

Actual total:
1,250,000

We have not confirmed that this is definitely happening, but the identical values observed on resumed/failed runs make this worth testing.


Suggested regression test for session usage

Example:

First Claude run reports:

input/cache/output cumulative total:
1,000,000

Resume same Claude session:

Claude now reports cumulative total:
1,250,000

Multica should attribute:

additional usage:
250,000

to the second task if the provider value is cumulative.

It should NOT attribute:

1,250,000

as entirely new consumption.


Proposed architecture change

We suggest placing an explicit orchestration/workflow layer between agents.

Instead of:

Developer Agent
    ↓ comment
Reviewer Agent
    ↓ comment
Developer Agent
    ↓ comment
Product Owner Agent

prefer:

                     ┌───────────────────┐
                     │ Workflow Engine   │
                     └─────────┬─────────┘
                               │
                        classify event
                               │
             ┌─────────────────┼─────────────────┐
             │                 │                 │
             ▼                 ▼                 ▼
        State change       Notification      Actual work
        no LLM             no heavy LLM      heavy agent
             │                 │                 │
             ▼                 ▼                 ▼
         update DB          post message       invoke agent
         assign role        update UI          bounded context

Suggested event classifications

Events that should usually NOT invoke a full coding agent

ACKNOWLEDGEMENT
STATUS_UPDATE
ASSIGNMENT_CHANGE
AGENT_COMPLETED
REVIEW_APPROVED
ROUTING_REQUEST
HANDOFF_NOTIFICATION
DELEGATION_FAILED
PROVIDER_LIMIT_REACHED
TASK_CANCELLED
TASK_ALREADY_COMPLETED

These can generally be handled by the platform/workflow engine.


Events that may require a full agent

IMPLEMENT_CODE
INVESTIGATE_BUG
REVIEW_CODE
FIX_REVIEW_FINDINGS
ANALYZE_FAILURE
RUN_TARGETED_DEBUGGING
ANSWER_TECHNICAL_REQUEST
DESIGN_CHANGE

Suggested structured agent result

Instead of an agent ending with:

"@Reviewer, I completed the implementation. Please review."

the agent could return:

json
{
  "outcome": "implementation_complete",
  "next_state": "review_required",
  "recommended_role": "reviewer",
  "requires_agent_execution": true,
  "branch": "feature/example",
  "changed_files": [
    "service.py",
    "repository.py"
  ],
  "summary": "Implemented the requested change and added regression tests."
}

The orchestration layer then performs:

IMPLEMENTATION_COMPLETE
        ↓
REVIEW_REQUIRED
        ↓
invoke reviewer

No additional developer LLM invocation is required for routing.


Suggested review result

Reviewer:

json
{
  "outcome": "changes_requested",
  "next_state": "implementation_required",
  "recommended_role": "developer",
  "requires_agent_execution": true,
  "blocking_findings": [
    "Missing validation",
    "Regression test required"
  ]
}

Again, routing is deterministic.


Add cross-agent loop detection

Multica should detect patterns such as:

Developer → Reviewer
Reviewer → Developer
Developer → Reviewer
Reviewer → Developer

Possible controls:

MAX_AGENT_HANDOFFS_PER_ISSUE
MAX_AUTOMATIC_AGENT_RUNS
MAX_SAME_PAIR_HANDOFFS
HANDOFF_WINDOW_MINUTES
MAX_REVIEW_CYCLES

Example:

Developer → Reviewer = cycle 1
Reviewer → Developer
Developer → Reviewer = cycle 2
Reviewer → Developer
Developer → Reviewer = cycle 3

At a configured threshold:

AUTO_HANDOFF_STOPPED

and transition the issue to something like:

NEEDS_COORDINATION

Example loop warning

Automatic agent handoff paused.

Detected repeated Developer ↔ Reviewer cycle.

Review cycles: 3
Outstanding findings: 2
Last commit: abc123
Current owner: Developer

Further automatic routing has been stopped to avoid agent churn.

This can be generated by the platform without another LLM invocation.


Context compaction

We recommend introducing automatic context compaction based on multiple signals.

Do not rely only on the number of tool calls.

Possible triggers:

active context > configurable token threshold

OR

retained tool-result tokens > configurable threshold

OR

tool calls since compaction > configurable threshold

OR

single tool output > configurable maximum

Conceptually:

python
if active_context_tokens > CONTEXT_LIMIT:
    checkpoint_and_rollover()

elif retained_tool_tokens > TOOL_HISTORY_LIMIT:
    compact_tool_history()

elif tool_calls_since_compaction > TOOL_CALL_LIMIT:
    compact_tool_history()

elif current_tool_output > TOOL_OUTPUT_LIMIT:
    store_as_artifact()

Suggested compact checkpoint format

Issue objective
---------------

What is being implemented/fixed?


Current state
-------------

IMPLEMENTATION_COMPLETE / REVIEW_REQUIRED / etc.


Important decisions
-------------------

- Decision 1
- Decision 2


Relevant files
--------------

- file1.py
- file2.py


Changed files
-------------

- file1.py
- test_file1.py


Current branch / MR
-------------------

branch-name
MR reference


Completed work
--------------

- implementation
- tests
- review finding #1


Tests
-----

42 passed
0 failed


Outstanding work
----------------

- performance test
- reviewer finding #2


Important artifacts
-------------------

diff: artifact://...
test log: artifact://...
benchmark: artifact://...


Next action
-----------

Reviewer performs targeted review.

This can be hundreds of tokens instead of tens of thousands.


Checkpoint-based session rollover

We recommend adding session rollover.

Example:

Agent session A
     │
     │ reaches context threshold
     ▼
Generate checkpoint
     │
     ▼
Close / stop resuming session A
     │
     ▼
Create fresh session B
     │
     ▼
Inject:
- stable system instructions
- compact project index
- checkpoint
- current task

This prevents one issue/agent session from growing indefinitely.


Bound tool results before they enter context

Ideally, token reduction should happen before large tool output is inserted.

Examples:

Source files

Instead of:

read file:
4,000 lines

prefer targeted retrieval:

symbol:
calculateSomething()

lines:
420–510

Git diff

Instead of:

11,000-line diff

return:

18 files changed
+821 / -305

Potentially important files:

auth_service.py
tenant_repository.py
test_auth_service.py

Full diff:
artifact://...

Tests

Instead of storing:

3,000 lines of pytest output

retain:

Tests:
148 passed
2 failed

Failures:

test_invalid_tenant
AssertionError at test_tenant.py:142

test_expired_token
Expected 401, got 200

Full log:
artifact://...

Make every agent invocation observable

One difficulty during investigation is understanding why each terminal task was created.

Please consider attaching a trigger reason to every agent execution.

Example:

USER_REQUEST
DIRECT_MENTION
REVIEW_REQUEST
CHANGES_REQUESTED
STATUS_TRANSITION
AGENT_HANDOFF
RETRY
FAILURE_RECOVERY
WEBHOOK
SCHEDULED
SYSTEM_ROUTING
MANUAL_RERUN

Then the UI could show:

Task #101
Agent: Developer
Trigger: CHANGES_REQUESTED

Task #102
Agent: Reviewer
Trigger: REVIEW_REQUEST

Task #103
Agent: Developer
Trigger: SYSTEM_ROUTING

Task #104
Agent: Product Owner
Trigger: DIRECT_MENTION

Task #105
Agent: Developer
Trigger: FAILURE_RECOVERY

This would make unnecessary executions immediately visible.


Add parent/correlation IDs

For tracing agent chains, it would also help to expose:

run_id
parent_run_id
trigger_event_id
issue_id
agent_id
session_id
handoff_id

Example:

run_id:          run-105
parent_run_id:   run-104
trigger:         FAILURE_RECOVERY
agent:           Developer
session:         claude-session-abc

This would allow users to reconstruct:

User
 ↓
Developer run 100
 ↓
Reviewer run 101
 ↓
Developer run 102
 ↓
Reviewer run 103
 ↓
PO run 104 [FAILED]
 ↓
Developer run 105

and identify churn very quickly.


Dashboard terminology

Currently a single large "tokens" number can be misleading because different token categories have different meanings and provider pricing.

We recommend making the primary usage view something li