Skip to content

fix(copilot): infer nested prompt schema from output definitions#100

Open
lesandiz wants to merge 2 commits intomicrosoft:mainfrom
lesandiz:fix-nested-output-schema-prompt
Open

fix(copilot): infer nested prompt schema from output definitions#100
lesandiz wants to merge 2 commits intomicrosoft:mainfrom
lesandiz:fix-nested-output-schema-prompt

Conversation

@lesandiz
Copy link
Copy Markdown

Summary

  • build the Copilot prompt schema recursively from nested output: definitions instead of flattening to top-level fields only
  • include nested object properties, required keys, and array item schemas in the prompt-facing schema used for initial guidance and parse recovery
  • add regression coverage for recursive schema generation and the actual prompt sent to Copilot

Validation

  • uv run --python 3.13 pytest tests\test_providers\test_copilot.py -q
  • uv run --python 3.13 conductor run C:\Users\lester.copilot\session-state\9a4adc0c-6650-46e6-9540-061d5b29a7ef\files\conductor-nested-output-repro.yaml --input topic="AI Harness Engineering"

Context

Build the Copilot prompt schema recursively from agent output definitions so nested object properties and array item schemas are surfaced to the model and parse-recovery flow.

Add regression tests for recursive schema generation and the actual prompt sent to Copilot.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lesandiz
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copy link
Copy Markdown
Collaborator

@jrob5756 jrob5756 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello - Thank you so much for your contribution to conductor. One small recommendation. If you can add this check, I'd be happy to merge.

Comment thread src/conductor/providers/copilot.py Outdated
f"than the raw JSON object."
)

def _build_prompt_schema(self, schema: dict[str, OutputField]) -> dict[str, Any]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing recursion depth limit — These three new recursive methods (_build_prompt_schema_build_prompt_field_schema_build_prompt_schema / _build_prompt_item_schema_build_prompt_item_schema) have no depth guard. A pathologically deep schema would cause a RecursionError crash.

The Claude provider already protects against this with _max_schema_depth = 10 and checks at the top of its corresponding methods (_build_json_schema_properties and _build_single_field_schema).

Suggested fix: add a depth parameter (default 0) to all three methods and raise ValidationError if depth > MAX_SCHEMA_DEPTH, matching Claude's pattern:

MAX_PROMPT_SCHEMA_DEPTH = 10

def _build_prompt_schema(self, schema: dict[str, OutputField], depth: int = 0) -> dict[str, Any]:
    if depth > self.MAX_PROMPT_SCHEMA_DEPTH:
        raise ValidationError(...)
    ...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing Jason. I applied your suggestion, following existing pattern in claude.py.

Prevent RecursionError on pathologically deep output schemas by adding
a depth parameter to _build_prompt_schema, _build_prompt_field_schema,
and _build_prompt_item_schema, matching the existing pattern in claude.py.

Co-Authored-By: Claude Opus 4.6 (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.

3 participants