Skip to content

Commit 60bd9a1

Browse files
committed
fix: support of before_agent_callback in case of a direct content response - fix PR comments
1 parent 9d418d3 commit 60bd9a1

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

typescript-sdk/integrations/adk-middleware/src/adk_middleware/adk_agent.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,10 +862,9 @@ async def _run_adk_in_background(
862862
):
863863

864864
final_response = adk_event.is_final_response()
865-
no_usage_response = not adk_event.usage_metadata
866865
has_content = adk_event.content and hasattr(adk_event.content, 'parts') and adk_event.content.parts
867866

868-
if not final_response or (no_usage_response and has_content):
867+
if not final_response or (not adk_event.usage_metadata and has_content):
869868
# Translate and emit events
870869
async for ag_ui_event in event_translator.translate(
871870
adk_event,

typescript-sdk/integrations/adk-middleware/src/adk_middleware/event_translator.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,13 @@ async def _translate_text_content(
174174
should_send_end = is_final_response and not is_partial
175175

176176
logger.info(f"📥 Text event - partial={is_partial}, turn_complete={turn_complete}, "
177-
f"is_final_response={is_final_response}, should_send_end={should_send_end}, "
178-
f"currently_streaming={self._is_streaming}")
179-
180-
# Skip final response events to avoid duplicate content, but send END if streaming
177+
f"is_final_response={is_final_response}, should_send_end={should_send_end}, "
178+
f"currently_streaming={self._is_streaming}")
179+
181180
if is_final_response:
182181

183182
# If a final text response wasn't streamed (not generated by an LLM) then deliver it in 3 events
184-
no_usage_response = not hasattr(adk_event, 'usage_metadata') or not adk_event.usage_metadata
185-
if not self._is_streaming and no_usage_response and should_send_end:
183+
if not self._is_streaming and not adk_event.usage_metadata and should_send_end:
186184
logger.info(f"⏭️ Deliver non-llm response via message events "
187185
f"event_id={adk_event.id}")
188186

0 commit comments

Comments
 (0)