Skip to content

Idempotent retries do not return the original tool result #35

@nficano

Description

@nficano

src/Internal/Runtime/ToolInvocationHandler.php:111 handles a repeated (principal, idempotency_key) by emitting a correlated Ack('replay') and returning before the tool runs. ARCPClient::invokeTool() only treats ToolResult, ToolError, and Nack as valid terminal responses, so the duplicate request either raises InvalidArgumentException for an unexpected Ack or times out depending on timing. The integration test in tests/Integration/JobLifecycleTest.php:123 documents this mismatch and intentionally avoids asserting a replayed value.

This breaks the public retry contract described in docs/guides/jobs.md:36 and docs/recipes.md:19, where callers are told to pass an IdempotencyKey so retries do not double-submit mutating work. Preventing the second execution is only half of the idempotency contract; the retry still needs to resolve consistently for the client.

Fix prompt: Change logical idempotency replay so the runtime replays or reconstructs the original terminal correlated response for the duplicate command. Store enough outcome data in the event log or query the stored outcome_message_id and send the original ToolResult or ToolError with the new request's correlation id. Update the idempotency integration test to assert that the second invokeTool() returns the same value without re-running the handler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingseverity:highHigh severity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions