RestatePlugin: after_model_callback never invoked - before_model_callback returns LlmResponse causing ADK to skip post-model hooks
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
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.
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.
- Dominant language
- Python
- Stars
- 81
- Forks
- 22
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 2
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.
More from restatedev/sdk-python
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
restatedev/sdk-python#223 · 1 comment ·
-
Difficulty 2/5 1-2 days Newbie friendliness 68/100
restatedev/sdk-python#204 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
restatedev/sdk-python#225 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
restatedev/sdk-python#222 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
restatedev/sdk-python#221 ·
All issues in restatedev/sdk-python
Similar issues
-
triage/confirmed
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
Difficulty 1/5 Under an hour Newbie friendliness 92/100
NousResearch/hermes-agent#118866 ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
apache/cloudstack#14222 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100