[fix] Resolve small open issues#4414
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:
✨ 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.
Pull request overview
This PR addresses a couple of small robustness issues across the evaluator execution templates and shared exception formatting.
Changes:
- Updated TypeScript evaluator templates to simplify numeric coercion/normalization of
evaluate()results. - Made
EntityCreationConflict.__str__resilient toconflict=Nonebefore iterating.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
sdks/python/agenta/sdk/engines/running/templates.py |
Adjusts TypeScript evaluator wrapper result handling/normalization logic. |
api/oss/src/core/shared/exceptions.py |
Guards conflict iteration in __str__ to avoid NoneType errors. |
Comments suppressed due to low confidence (2)
sdks/python/agenta/sdk/engines/running/templates.py:142
- The TypeScript template now annotates
resultasnumber | null, which can break compilation when user-providedevaluate()returns a string (or is inferred to return a string) even though the wrapper later coerces viaNumber(...). To keep the template compatible with evaluators returningstring | number | null, avoid narrowing the type here (e.g., useunknown/anyfor the raw result and only type the coerced value).
// Execute and capture result
let result: number | null = evaluate(inputs, outputs, trace);
// Ensure result is a number
const resultNum = Number(result);
result = Number.isFinite(resultNum) ? resultNum : null;
sdks/python/agenta/sdk/engines/running/templates.py:142
- Coercing with
Number(result)will turn an explicitnullreturn fromevaluate()into0, so a user trying to signal “no score” vianullgets recorded as a numeric score instead. Ifnullis meant to be preserved (the runner acceptsnull), add an explicit check fornull/undefinedbefore numeric coercion sonullstaysnull.
// Ensure result is a number
const resultNum = Number(result);
result = Number.isFinite(resultNum) ? resultNum : null;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Execute and capture result | ||
| let result = evaluate(app_params, inputs, output, correct_answer); | ||
| let result: number | null = evaluate(app_params, inputs, output, correct_answer); | ||
|
|
||
| // Ensure result is a number | ||
| result = Number(result); | ||
| if (!Number.isFinite(result)) {{ | ||
| result = null; | ||
| }} | ||
| const resultNum = Number(result); | ||
| result = Number.isFinite(resultNum) ? resultNum : null; |
| // Ensure result is a number | ||
| result = Number(result); | ||
| if (!Number.isFinite(result)) {{ | ||
| result = null; | ||
| }} | ||
| const resultNum = Number(result); | ||
| result = Number.isFinite(resultNum) ? resultNum : null; |
Railway Preview Environment
|
No description provided.