restatedev / restatedev/sdk-python
RestatePlugin: after_model_callback never invoked - before_model_callback returns LlmResponse causing ADK to skip post-model hooks
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 81
- Forks
- 22
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 2
Description
Bug Description
When registering additional plugins, alongside Restate (in our case it was for ADK-level observability), after_model_callback is never invoked. This makes it impossible to access the model response and usage metadata in post-call hook, which is the natural place to capture $ai_generation events.
Environment
restate-sdk(version 0.16.0)google-adk(1.28.1)RestatePlugin
Root Cause
The ADK framework uses the return value of before_model_callback as a signal:
None-> proceed with the real model call, then invokeafter_model_callbackLlmResponse-> short-circuit: skip the model call and skipafter_model_callback
RestatePlugin.before_model_callback wraps the LLM call inside a Restate durable step, which means it executes the model call itself and returns a LlmResponse. This is correct for Restate's replay semantics, but it has a side effect: after_model_callback is never reached, regardless of what subclasses implement there.
Workaround
Our current workaround is to subclass (decorate) the RestatePlugin itself, so we can simulate the after_model_callback trigger inside the wrapped before_model_callback call, but we believe this is worth tracking and resolving.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing RestatePlugin.before_model_callback and the Google ADK handling of before_model_callback return values. Compare that flow with after_model_callback and the reported subclass workaround. Done means the post-model hook can receive the model response and usage metadata when additional plugins are registered, without breaking Restate replay semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100