restatedev / restatedev/sdk-python
RestatePlugin: after_model_callback never invoked - before_model_callback returns LlmResponse causing ADK to skip post-model hooks
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 81
- Fork
- 22
- Merge medio
- 2g 2h
- PR unite (30g)
- 2
Descrizione
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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia tracciando RestatePlugin.before_model_callback e la gestione da parte di Google ADK dei valori restituiti da before_model_callback. Confronta questo flusso con after_model_callback e con il workaround tramite sottoclasse riportato. Il lavoro è completato quando l’hook post-modello può ricevere la risposta del modello e i metadati di utilizzo quando sono registrati plugin aggiuntivi, senza compromettere la semantica di replay di Restate.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100