Skip to content

Fix temporal worker imports and streaming tutorial for CI#291

Merged
danielmillerp merged 3 commits intomainfrom
dm/retrigger-tutorial-tests
Mar 24, 2026
Merged

Fix temporal worker imports and streaming tutorial for CI#291
danielmillerp merged 3 commits intomainfrom
dm/retrigger-tutorial-tests

Conversation

@danielmillerp
Copy link
Contributor

@danielmillerp danielmillerp commented Mar 24, 2026

Summary

  • Fix temporal worker imports: Remove deprecated _JSONTypeConverterUnhandled usage and lazy-import OpenAIAgentsPlugin to avoid pulling in opentelemetry.sdk for non-Temporal agents
  • Fix 020_streaming tutorial: Correct TextContent import path and fix import sorting for ruff
  • Improve CI failure diagnostics: Print agent logs and Docker server logs on test failure for easier debugging

Test plan

  • All 33 CI checks pass (lint, build, test, all tutorials)
  • ruff import sorting verified locally

🤖 Generated with Claude Code

Greptile Summary

This PR fixes two categories of known tutorial test failures — all ten temporal agent tests and the 020_streaming sync test — and updates the CI failure-logging step for better diagnostics. The temporal fixes are clean and well-reasoned. The streaming fix correctly addresses both the wrong TextContent import module and the missing return that would have caused execution to fall through after the "no API key" early-exit yield.

Key changes:

  • worker.py: Removes the now-deleted private _JSONTypeConverterUnhandled type from import and type annotation; moves OpenAIAgentsPlugin import inside get_temporal_client to make it lazy and avoid pulling in opentelemetry.sdk at module load time for non-temporal agents.
  • 020_streaming/acp.py: Corrects TextContent import (task_message_contenttext_content) and adds the missing return after the error yield, preventing fall-through into the normal message handling path.
  • CI workflow: Failure-logging now reads from /tmp/agentex-*.log (where run_agent_test.sh actually writes) and appends Docker compose logs for the agentex service.
  • Missing: The PR description lists 030_langgraph as a third fix (invalid gpt-5 model + unsupported reasoning parameter on gpt-4o-mini), but no changes to 030_langgraph/project/graph.py are included in the diff. That test will continue to fail.

Confidence Score: 4/5

  • Safe to merge for the two categories of fixes it actually delivers; the langgraph tutorial test will remain broken.
  • All implemented changes are correct and targeted. The temporal and streaming fixes are well-tested by the CI matrix. The only gap is that the PR's own stated third fix (030_langgraph model/reasoning config) is absent from the diff, so one tutorial will still fail in CI after this merges.
  • examples/tutorials/00_sync/030_langgraph/project/graph.py — listed in the PR description as needing a fix but not changed in this PR

Important Files Changed

Filename Overview
src/agentex/lib/core/temporal/workers/worker.py Removes the removed private _JSONTypeConverterUnhandled type from the import list and the to_typed_value return annotation, and moves the OpenAIAgentsPlugin import inside get_temporal_client to make it lazy. Both changes are correct and targeted.
examples/tutorials/00_sync/020_streaming/project/acp.py Two real bugs fixed: TextContent was imported from the wrong module (task_message_contenttext_content), and the early-return path after the "no API key" yield was missing a return, allowing execution to fall through into the normal handler logic.
.github/workflows/agentex-tutorials-test.yml Failure-logging step updated to read agent logs from /tmp/agentex-*.log and Docker compose logs. The cd ../../scale-agentex/agentex assumes a sibling-repo layout but fails gracefully via `

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Temporal Worker Start] --> B{plugins empty?}
    B -- No --> C[_validate_plugins]
    B -- Yes --> D[Lazy import OpenAIAgentsPlugin]
    C --> D
    D --> E{has_openai_plugin?}
    E -- Yes --> F[Connect without custom data_converter]
    E -- No --> G[Connect with DateTimePayloadConverter]
    F --> H[Client.connect]
    G --> H

    subgraph 020_streaming fix
        I[handle_message_send] --> J{OPENAI_API_KEY set?}
        J -- No --> K[yield StreamTaskMessageFull error msg]
        K --> L[return ← NEW]
        J -- Yes --> M[Stream agent response]
    end
Loading

Comments Outside Diff (1)

  1. examples/tutorials/00_sync/030_langgraph/project/graph.py, line 23-50 (link)

    030_langgraph fix missing from this PR

    The PR description lists fixing the 030_langgraph tutorial as one of its goals — "Used gpt-5 (invalid model) with reasoning parameter (unsupported on gpt-4o-mini)" — but graph.py is unchanged in this diff. MODEL_NAME is still "gpt-5" and the ChatOpenAI constructor still passes reasoning={"effort": "high", "summary": "auto"} on line 49, which is the exact configuration the description identifies as causing the test failure.

    If this file wasn't intentionally left out, the fix (updating MODEL_NAME and removing the reasoning kwarg) needs to be included before this PR can deliver on its stated goal of passing all three categories of tutorial test failures.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: examples/tutorials/00_sync/030_langgraph/project/graph.py
Line: 23-50

Comment:
**030_langgraph fix missing from this PR**

The PR description lists fixing the `030_langgraph` tutorial as one of its goals — "Used `gpt-5` (invalid model) with `reasoning` parameter (unsupported on `gpt-4o-mini`)" — but `graph.py` is unchanged in this diff. `MODEL_NAME` is still `"gpt-5"` and the `ChatOpenAI` constructor still passes `reasoning={"effort": "high", "summary": "auto"}` on line 49, which is the exact configuration the description identifies as causing the test failure.

If this file wasn't intentionally left out, the fix (updating `MODEL_NAME` and removing the `reasoning` kwarg) needs to be included before this PR can deliver on its stated goal of passing all three categories of tutorial test failures.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (7): Last reviewed commit: "Fix import sorting lint and revert langg..." | Re-trigger Greptile

danielmillerp and others added 2 commits March 24, 2026 13:17
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- worker.py: Remove private _JSONTypeConverterUnhandled import (removed
  in newer temporalio) and lazy-import OpenAIAgentsPlugin to avoid
  opentelemetry.sdk dependency at import time. Fixes all 10 temporal
  tutorial tests.
- 020_streaming/acp.py: Fix TextContent import path and add missing
  return after error yield.
- 030_langgraph/graph.py: Change model from gpt-5 (invalid) to
  gpt-4o-mini, remove unsupported reasoning parameter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@danielmillerp danielmillerp changed the title Fix docstring test command path in tutorial test Fix tutorial test failures across sync and temporal agents Mar 24, 2026
@danielmillerp danielmillerp force-pushed the dm/retrigger-tutorial-tests branch 3 times, most recently from 777ae44 to d881da8 Compare March 24, 2026 18:11
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@danielmillerp danielmillerp force-pushed the dm/retrigger-tutorial-tests branch from d881da8 to 1dd4ef9 Compare March 24, 2026 20:10
@danielmillerp danielmillerp changed the title Fix tutorial test failures across sync and temporal agents Fix temporal worker imports and streaming tutorial for CI Mar 24, 2026
@danielmillerp danielmillerp merged commit 1ffe32f into main Mar 24, 2026
36 checks passed
@danielmillerp danielmillerp deleted the dm/retrigger-tutorial-tests branch March 24, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant