continue icon indicating copy to clipboard operation
continue copied to clipboard

Conflicting Instructions: Parallel vs Sequential Tool Calling

Open shanevcantwell opened this issue 11 months ago • 6 comments

Before submitting your bug report

Relevant environment info

- OS: any
- Continue version: 1.3.28 (verified against main branch)
- IDE version: any
- Model: any (all models receive conflicting instructions)
- config: any

Description

Conflicting Instructions: Parallel vs Sequential Tool Calling

Summary

Models receive contradictory instructions about whether to call tools in parallel or sequentially. This causes unpredictable behavior that varies by provider and model.

The Conflict

Three different instructions exist in the same context:

  1. Agent system message (defaultSystemMessages.ts:66):

    "If you need to use multiple tools, you can call multiple read-only tools simultaneously."
    
  2. System message tools framework (toolCodeblocks/index.ts:74):

    "You can only call ONE tool at at time."
    
  3. Edit tool definitions (editFile.ts:11):

    "This tool CANNOT be called in parallel with other tools."
    

How It Happens

modelSupportsNativeTools(model)?
├── YES → Native function calling
│         └── Gets: "simultaneously" + per-tool "CANNOT parallel"
│
└── NO  → System message codeblocks
          └── Gets: "simultaneously" (agent message)
                  + "ONE tool at a time" (codeblock framework)
                  + per-tool "CANNOT parallel"

When using system-message tools, models receive BOTH "call tools simultaneously" AND "only ONE tool at a time" in the same prompt.

Proposed Fix

Replace the scattered instructions with a single, clear policy in one location:

"Call tools one at a time, waiting for each result before proceeding."

If parallel read-only tools should be allowed for native tool calling, add that exception only when modelSupportsNativeTools() returns true, and remove it from the base agent system message.

Related Issues

  • #5590 - MCP Agent fails when handling multiple tool calls
  • #5469 - User couldn't get tools working despite research

To reproduce

No response

Log output


shanevcantwell avatar Dec 25 '25 02:12 shanevcantwell

Related issues about tool calling behavior:

  • #5590 - MCP Agent Mode Fails to Handle Multiple Tools call - JSON.parse Error (CLOSED)
  • #7429 - Continue MCP Agent with gpt-oss: multi-action sequences fail -- only first action runs (OPEN)
  • #4377 - Multiple function calls of the same type are combined (OPEN)
  • #7387 - Duplicate tool execution output after Edit in Agent mode (OPEN)
  • #5312 - Only the last of multiple function call will be called (CLOSED)

continue avatar Dec 25 '25 02:12 continue

This issue hasn't been updated in 90 days and will be closed after an additional 10 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue.

github-actions[bot] avatar Mar 25 '26 02:03 github-actions[bot]

This problem is still relevant.

VeraKowalczuk avatar Mar 25 '26 15:03 VeraKowalczuk

This is a well-documented example of a broader architectural problem: asking a model to be its own scheduler.

The root issue isn't just contradictory instructions — it's that parallelism decisions are being pushed into the system prompt as natural-language rules the model has to interpret and follow correctly every single time. In practice, models are unreliable at conditional scheduling logic ("parallel if read-only, sequential if write"). They'll get it right 90% of the time, which means you get silent file corruption or race conditions on the other 10%. The failure mode is particularly nasty because it's intermittent — works fine in testing, blows up in production on a slightly different prompt.

We hit this exact problem building a multi-agent orchestrator. Our solution was to take the parallelism decision away from the model entirely. The runtime maintains a dependency graph: tasks declare depends_on relationships, and independent tasks get dispatched concurrently while dependent ones wait. The model's job is to execute one focused task well — it never sees instructions about parallel vs sequential because it doesn't make that decision.

Concretely, the orchestrator builds a DAG each tick, computes the parallel width from the graph topology, and only spawns agents for tasks whose dependencies are all satisfied. File-level locks prevent two agents from touching the same file simultaneously, regardless of what any model "decides" to do. An adaptive controller scales concurrency up or down based on the observed error rate over a sliding window — if failures spike above 20%, it automatically reduces parallelism.

For Continue's specific case, I think the proposed fix of "call tools one at a time" is pragmatically correct but leaves performance on the table. A better path would be:

  1. Strip all parallelism instructions from system prompts and tool descriptions entirely
  2. Have the runtime classify tools as read-only vs mutating (this is already known at definition time)
  3. The runtime batches concurrent read-only calls when the provider supports parallel tool use, and serializes anything involving writes
  4. The model just calls tools — it never needs to know about the scheduling policy

This keeps the model focused on what it's good at (reasoning about which tools to call and with what arguments) and puts scheduling logic in deterministic code where it can be tested, debugged, and reasoned about. Natural-language scheduling constraints in system prompts are a foot-gun — they can't be unit tested, they vary by model, and they degrade unpredictably with prompt length.

For reference, the dependency graph + file locking approach is what we use in Bernstein (https://github.com/chernistry/bernstein) — happy to go deeper on the specific failure modes we saw before moving parallelism decisions out of prompt-space.

chernistry avatar Apr 06 '26 17:04 chernistry

This issue hasn't been updated in 90 days and will be closed after an additional 10 days without activity. If it's still important, please leave a comment and share any new information that would help us address the issue.

github-actions[bot] avatar Jul 06 '26 02:07 github-actions[bot]

This issue was closed because it wasn't updated for 10 days after being marked stale. If it's still important, you are welcome to leave a comment and this will keep the issue open. However please note that this repo is no longer being actively maintained.

github-actions[bot] avatar Jul 17 '26 02:07 github-actions[bot]