Skip to content

feat(server): Align condition and template depth limits#166

Open
lan17 wants to merge 1 commit intomainfrom
codex/align-condition-template-depth-limits
Open

feat(server): Align condition and template depth limits#166
lan17 wants to merge 1 commit intomainfrom
codex/align-condition-template-depth-limits

Conversation

@lan17
Copy link
Copy Markdown
Contributor

@lan17 lan17 commented Apr 7, 2026

Summary

  • increase the shared condition nesting depth limit from 6 to 12
  • make MAX_TEMPLATE_DEFINITION_DEPTH derive from MAX_CONDITION_DEPTH so both limits stay aligned
  • expand the condition-depth model test to verify depth 12 succeeds and depth 13 still fails

Why

The condition-tree limit had been raised independently, but the template definition depth used a separate constant value. Referencing the shared constant removes drift and keeps template-backed controls aligned with the same supported nesting depth.

Impact

Template-backed and non-template control validation now share one source of truth for depth limits. Future changes to the condition limit will automatically apply to template definition depth as well.

Validation

  • make test TEST= models/tests/test_controls.py (this invoked the repo's full default make test chain and passed across models, telemetry, server, engine, Python SDK, and builtin evaluators)
  • make models-test

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@lan17 lan17 changed the title [codex] Align condition and template depth limits feat(server): Align condition and template depth limits Apr 7, 2026
@lan17 lan17 marked this pull request as ready for review April 7, 2026 20:01
type TemplateValue = str | bool | list[str]
type JsonValue = JSONValue

MAX_CONDITION_DEPTH = 12
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do you think a normal usecase would need this much depth? what was hte motivation behind doubling it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They might depending on how complex the Control is, which they might get complex if we generate them using LLMs (which i did for Leon The Controller).

IMO we should not dictate a shallow depth just because we are afraid users will misuse it. We should leave it up to them. We should have some depth that prevents some perf issues tho, so I would push this limit even higher in the future.

with pytest.raises(
ValidationError,
match="Condition nesting depth exceeds maximum of 6",
match="Condition nesting depth exceeds maximum of 12",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we use the constant MAX_CONDITION_DEPTH here instead?

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.

2 participants