github / github/copilot-cli

Constrain `run_factory` to registered factory names to prevent repeated guesses

Open
#4,425 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:agents area:tools
Dominant language
Shell
Stars
11.2k
Forks
1.9k
Avg merge
14h 16m
Merged PRs (30d)
6

Description

Summary

run_factory can be exposed with an unconstrained name argument even when no matching factory is registered. The model can interpret tool availability as factory availability, invent plausible names, and retry them serially.

Originally reported from the VS Code Agents Window in microsoft/vscode#329551.

Observed behavior

With Copilot CLI 1.0.78 and GPT-5.6 Sol, one session produced 13 distinct model-authored run_factory calls. Every call failed immediately with:

RpcResponseError: No factory registered with name "<name>"

The model first tried eight implementation-oriented names:

  • apply_finding
  • code_implementation_factory
  • single_task
  • implementation
  • code-task
  • fix-factory
  • repo_task
  • review_then_implement

It later tried five more names for video analysis:

  • video_analysis
  • analyze_video
  • single_video_analysis
  • video-analysis
  • media_analysis

These were separate assistant-authored calls after each rejection, not host retries. No factory ran.

Steps to reproduce
  1. Expose run_factory in a session where no matching factories are registered.
  2. Ask the agent to perform a routine single-session task, such as a small implementation or media-analysis task.
  3. Observe that the model may invent and repeatedly retry factory names.
Expected behavior

Invalid factory names should be impossible or strongly bounded. Ideally:

  • Dynamically constrain name to registered factory names.
  • Do not expose run_factory when there are no registered factories or resumable runs.
  • If dynamic enum generation is not possible, require registry discovery before invocation and include available names in validation errors.
  • Enforce exactly one of name and resumeFromRunId at the schema level.
Actual behavior

name is effectively a free-form string, so failures occur only after a costly tool round trip. Prompt guidance to use factories selectively did not prevent repeated guesses.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the run_factory tool schema, factory registry, and validation path in the repository. Trace how registered names and resumable runs are exposed, then identify existing tests for tool invocation or schema validation; done means invalid names are bounded before a tool round trip and name/resumeFromRunId exclusivity is enforced.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.