feat(openai): support handoffs#82
Conversation
|
|
||
|
|
||
| def from_cadence_handoff(ch: CadenceHandoff) -> Handoff[Any, Any]: | ||
| async def noop_invoke(_ctx: RunContextWrapper[Any], _json: str) -> Awaitable[Any]: # type: ignore[return] |
There was a problem hiding this comment.
💡 Bug: Incorrect return type on async noop_invoke callback
The noop_invoke function is declared as async def with return type -> Awaitable[Any]. Since async def functions implicitly wrap their return value in a coroutine (which is an Awaitable), this annotation means the actual type at the call site would be Awaitable[Awaitable[Any]], which is incorrect. The # type: ignore[return] comment is masking this issue. The return type should be -> Any (or -> None since it only raises).
Suggested fix:
async def noop_invoke(_ctx: RunContextWrapper[Any], _json: str) -> Any:
raise RuntimeError("Handoff invocation is handled by the runner, not the model")
Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion
| cadence_registry = cadence.Registry() | ||
| cadence_registry.register_activities(OpenAIActivities()) |
There was a problem hiding this comment.
💡 Quality: Module-level side effect in cadence_registry.py
cadence_registry.py instantiates OpenAIActivities() and registers it at import time. This means merely importing the module triggers side effects (object creation, registration). Consider using a factory function or lazy initialization pattern so consumers have explicit control over when registration happens.
Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion
Signed-off-by: Shijie Sheng <liouvetren@gmail.com>
Signed-off-by: Shijie Sheng <liouvetren@gmail.com>
9d6ee7a to
4d05ca9
Compare
Code Review 👍 Approved with suggestions 0 resolved / 2 findingsAdds OpenAI handoff support to the Cadence Python client. Consider removing the unused 💡 Bug: Incorrect return type on async noop_invoke callback📄 cadence/contrib/openai/cadence_handoff.py:33 📄 cadence/contrib/openai/cadence_handoff.py:6 The Suggested fix💡 Quality: Module-level side effect in cadence_registry.py📄 cadence/contrib/openai/cadence_registry.py:5-6 cadence_registry.py instantiates 🤖 Prompt for agentsOptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
What changed?
Why?
handoff is not serializable. We need an Cadence friendly entity in between
How did you test it?
Locally tested with a handoff agent. I'll upload the demo to cadence samples later when we have the new release

Potential risks
Release notes
Documentation Changes