feat(sdk): unify structured prompt rendering#4331
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR implements WP-B2 rendering unification by introducing a shared structured rendering layer ( ChangesWP-B2 Rendering Unification
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
sdks/python/oss/tests/pytest/unit/test_jinja2_sandbox.py (1)
21-22: ⚡ Quick winAssert a concrete exception type for sandbox violations.
Line 21 uses
pytest.raises(Exception), which can pass on unrelated failures. Please assert the actual contract type (or wrapper type) to keep this test precise.Suggested tightening
+from agenta.sdk.utils.lazy import _load_jinja2 ... def test_handlers_jinja2_blocks_ssti_payload() -> None: - with pytest.raises(Exception): + _, TemplateError = _load_jinja2() + with pytest.raises(TemplateError): _format_with_template( content=SSTI_PAYLOAD, format="jinja2", kwargs={}, )sdks/python/oss/tests/pytest/unit/test_render_template_helper.py (1)
786-789: ⚡ Quick winUse a specific exception assertion here, not
Exception.Line 788 is too broad and may hide unrelated failures. Match the concrete Jinja sandbox exception contract (consistent with the rest of this file).
Suggested tightening
def test_handlers_format_with_template_jinja2_raises_on_sandbox_violation(): payload = "{{ lipsum.__globals__['os'].popen('id').read() }}" - with pytest.raises(Exception): + _, TemplateError = _load_jinja2() + with pytest.raises(TemplateError): _format_with_template(content=payload, format="jinja2", kwargs={})
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a774c3b6-f63f-470d-b5c0-c819b76d7fce
📒 Files selected for processing (15)
docs/design/prompt-runtime-unification/README.mddocs/design/prompt-runtime-unification/wp-b2-rendering-unification/README.mddocs/design/prompt-runtime-unification/wp-b2-rendering-unification/plan.mddocs/design/prompt-runtime-unification/wp-b2-rendering-unification/qa.mddocs/design/prompt-runtime-unification/wp-b2-rendering-unification/research.mddocs/design/prompt-runtime-unification/wp-b2-rendering-unification/rfc.mddocs/design/prompt-runtime-unification/wp-b2-rendering-unification/status.mdsdks/python/agenta/sdk/engines/running/handlers.pysdks/python/agenta/sdk/utils/rendering.pysdks/python/agenta/sdk/utils/types.pysdks/python/oss/tests/pytest/unit/test_auto_ai_critique_v0_runtime.pysdks/python/oss/tests/pytest/unit/test_jinja2_sandbox.pysdks/python/oss/tests/pytest/unit/test_prompt_template_extensions.pysdks/python/oss/tests/pytest/unit/test_render_template_helper.pysdks/python/oss/tests/pytest/unit/test_structured_rendering.py
Railway Preview Environment
Updated at 2026-05-15T11:29:42.394Z |
QA
Potential next testRegression Tests
Edge Cases
|
Summary
Implements WP-B2 for prompt runtime unification.
agenta.sdk.utils.renderingwithrender_messages(...),render_json_like(...), and typedStructuredRenderingError.PromptTemplate.format(...)through the structured renderer while preservingTemplateFormatErrorfor chat/completion callers.auto_ai_critique_v0(...)through the shared renderer for prompt messages and judgejson_schemarendering.PromptFormattingV0Errorinstead of silently sending unrendered content to the LLM.PromptTemplateand LLM-as-a-judge.Validation
cd sdks/python && uv run ruff format agenta/sdk/utils/rendering.py agenta/sdk/utils/types.py agenta/sdk/engines/running/handlers.py oss/tests/pytest/unit/test_structured_rendering.py oss/tests/pytest/unit/test_auto_ai_critique_v0_runtime.py oss/tests/pytest/unit/test_prompt_template_extensions.py oss/tests/pytest/unit/test_jinja2_sandbox.py oss/tests/pytest/unit/test_render_template_helper.pycd sdks/python && uv run ruff check --fix agenta/sdk/utils/rendering.py agenta/sdk/utils/types.py agenta/sdk/engines/running/handlers.py oss/tests/pytest/unit/test_structured_rendering.py oss/tests/pytest/unit/test_auto_ai_critique_v0_runtime.py oss/tests/pytest/unit/test_prompt_template_extensions.py oss/tests/pytest/unit/test_jinja2_sandbox.py oss/tests/pytest/unit/test_render_template_helper.pycd sdks/python && uv run pytest oss/tests/pytest/unit -qResult:
411 passed, 3 warnings.