Skip to content

add support for Temporal PayloadCodec#328

Merged
declan-scale merged 7 commits intomainfrom
endre/payload-codec
Apr 21, 2026
Merged

add support for Temporal PayloadCodec#328
declan-scale merged 7 commits intomainfrom
endre/payload-codec

Conversation

@eberki-scale
Copy link
Copy Markdown
Contributor

@eberki-scale eberki-scale commented Apr 20, 2026

Greptile Summary

This PR adds opt-in PayloadCodec support throughout the Temporal integration layer — from TemporalACPConfig and FastACP.create down to TemporalClient, TemporalACP, and AgentexWorker — so callers can plug in encryption or compression codecs at both the ACP (client) and worker sides. The previous concern about silent codec dropping when OpenAIAgentsPlugin is present is resolved by promoting it to an explicit ValueError on both paths.

Confidence Score: 5/5

Safe to merge; all remaining findings are P2 style suggestions.

The core behavioral change (explicit ValueError instead of silent drop) directly addresses the previous review concern. Codec propagation is consistent across client and worker paths and is well-covered by the new test suite. The only open item is a P2 inconsistency in TemporalACPConfig where payload_codec lacks the same @field_validator guard applied to plugins and interceptors.

src/agentex/lib/types/fastacp.py — payload_codec field lacks runtime type validation.

Important Files Changed

Filename Overview
src/agentex/lib/core/clients/temporal/temporal_client.py Added payload_codec parameter to __init__, create, and _get_temporal_client; correctly stored and propagated to get_temporal_client.
src/agentex/lib/core/clients/temporal/utils.py Added payload_codec to get_temporal_client; raises ValueError when both OpenAI plugin and codec are present; attaches codec via dataclasses.replace when provided.
src/agentex/lib/core/temporal/workers/worker.py Added payload_codec to AgentexWorker and its get_temporal_client helper; same guard against OpenAI plugin conflict as the client-side utility.
src/agentex/lib/sdk/fastacp/impl/temporal_acp.py Added payload_codec field to TemporalACP.__init__ and create; forwarded to TemporalClient.create in the lifespan function.
src/agentex/lib/sdk/fastacp/fastacp.py Added payload_codec forwarding from TemporalACPConfig to TemporalACP.create via the hasattr pattern consistent with other fields.
src/agentex/lib/types/fastacp.py Added payload_codec: Any field to TemporalACPConfig with documentation, but lacks a @field_validator unlike plugins and interceptors.
tests/lib/test_payload_codec.py Comprehensive test coverage for all new codec paths across client utils, worker utils, AgentexWorker, TemporalACP, and FastACP config forwarding.

Sequence Diagram

sequenceDiagram
    participant User
    participant FastACP
    participant TemporalACP
    participant TemporalClient
    participant get_temporal_client
    participant Temporal

    User->>FastACP: create("async", config=TemporalACPConfig(payload_codec=codec))
    FastACP->>TemporalACP: create(temporal_address, plugins, interceptors, payload_codec)
    Note over TemporalACP: stores _payload_codec

    Note over TemporalACP: lifespan startup
    TemporalACP->>TemporalClient: create(temporal_address, plugins, payload_codec)
    TemporalClient->>get_temporal_client: get_temporal_client(..., payload_codec)
    alt has_openai_plugin AND payload_codec is not None
        get_temporal_client-->>User: raise ValueError
    else no conflict
        get_temporal_client->>get_temporal_client: dataclasses.replace(data_converter, payload_codec=codec)
        get_temporal_client->>Temporal: Client.connect(data_converter=patched_converter)
        Temporal-->>get_temporal_client: client
    end
    get_temporal_client-->>TemporalClient: client
    TemporalClient-->>TemporalACP: TemporalClient instance

    User->>AgentexWorker: AgentexWorker(payload_codec=codec)
    AgentexWorker->>get_temporal_client: get_temporal_client(..., payload_codec)
    get_temporal_client->>Temporal: Client.connect(data_converter=patched_converter)
Loading

Fix All in Cursor Fix All in Claude Code

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/agentex/lib/types/fastacp.py
Line: 66

Comment:
**`payload_codec` accepts any value without type-checking**

`plugins` and `interceptors` both have `@field_validator` methods that call runtime validators (`validate_client_plugins` / `validate_worker_interceptors`). `payload_codec` is typed as `Any` and has no validator, so an object that doesn't implement `PayloadCodec` will pass Pydantic validation and only fail deep inside Temporal's encode/decode path at runtime.

Consider either adding a `@field_validator` (e.g., checking `isinstance(v, PayloadCodec)`) or configuring `model_config = ConfigDict(arbitrary_types_allowed=True)` and narrowing the annotation to `PayloadCodec | None`:

```python
from pydantic import ConfigDict

class TemporalACPConfig(AsyncACPConfig):
    model_config = ConfigDict(arbitrary_types_allowed=True)
    ...
    payload_codec: PayloadCodec | None = Field(default=None, frozen=True)
```

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

Reviews (3): Last reviewed commit: "add override annotations to codec and pl..." | Re-trigger Greptile

@eberki-scale eberki-scale changed the title add support for temporal PayloadCodec add support for Temporal PayloadCodec Apr 20, 2026
Comment thread src/agentex/lib/core/clients/temporal/utils.py
Comment thread src/agentex/lib/core/temporal/workers/worker.py
Comment thread src/agentex/lib/core/clients/temporal/utils.py
Copy link
Copy Markdown
Contributor

@declan-scale declan-scale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add tests for this? Otherwise looks good

@eberki-scale
Copy link
Copy Markdown
Contributor Author

@declan-scale thank you for the review! added the tests.

@declan-scale declan-scale merged commit d88104b into main Apr 21, 2026
32 checks passed
@declan-scale declan-scale deleted the endre/payload-codec branch April 21, 2026 13:42
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.

2 participants