fix(copilot): infer nested prompt schema from output definitions#100
fix(copilot): infer nested prompt schema from output definitions#100lesandiz wants to merge 2 commits intomicrosoft:mainfrom
Conversation
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>
|
@microsoft-github-policy-service agree |
jrob5756
left a comment
There was a problem hiding this comment.
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.
| f"than the raw JSON object." | ||
| ) | ||
|
|
||
| def _build_prompt_schema(self, schema: dict[str, OutputField]) -> dict[str, Any]: |
There was a problem hiding this comment.
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(...)
...There was a problem hiding this comment.
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>
Summary
output:definitions instead of flattening to top-level fields onlyValidation
Context