Skip to content

Enforce max timeout for AgentCore invoke call - #132

Merged
justinschoeff merged 1 commit into
mainfrom
schoeff/agentcore-fix
Sep 16, 2026
Merged

justinschoeff merged 1 commit into
mainfrom
schoeff/agentcore-fix

Conversation

@justinschoeff

@justinschoeff justinschoeff commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

The AgentCore API is synchronous and while it does support streaming
responses, that is left up to the runtime code itself. This means the
invocation request can hang up to 8 hours!

Even when runtimes last a minute it is problematic for WCI. This commit
aims to limit the allowed runtime to 5 seconds and assuming success.

What was changed

Add a timeout via context to the AWS AgentCore SDK InvokeAgentRuntime call to prevent it from hitting the activity timeout. This also adds an http trace on request write as a gauge to whether the invocation was actually transmitted or not.

Why?

Without this, the runtime can hit the activity timeout causing retries and create worker-deployment failures. Additionally, each call (including retries) does spin up a new worker agentcore side.

Checklist

  1. Closes

  2. How was this tested:
    Launched an agent runtime that exceeded the 60s activity timeout and saw success alongside a consistent 5s between activity start to completed (hitting the agentCoreMaxRuntime.

Launched an agent runtime that responded immediately and saw success.

  1. Any docs updates needed?

@justinschoeff
justinschoeff force-pushed the schoeff/agentcore-fix branch 2 times, most recently from 55dceb9 to 29b535b Compare September 14, 2026 18:00
Comment thread wci/workflow/compute_provider/aws_agentcore.go Outdated
Comment thread wci/workflow/compute_provider/aws_agentcore.go
@justinschoeff
justinschoeff marked this pull request as ready for review September 14, 2026 20:35
@justinschoeff
justinschoeff requested a review from a team as a code owner September 14, 2026 20:35
The AgentCore API is synchronous and while it does support streaming
responses, that is left up to the runtime code itself. This means the
invocation request can hang up to 8 hours!

Even when runtimes last a minute it is problematic for WCI. This commit
aims to limit the allowed runtime to 5 seconds and assuming success.
@github-actions

Copy link
Copy Markdown

Merging this branch will not change overall coverage

Impacted Packages Coverage Δ 🤖
github.com/temporalio/temporal-auto-scaled-workers/wci/workflow/compute_provider 0.00% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/temporalio/temporal-auto-scaled-workers/wci/workflow/compute_provider/aws_agentcore.go 0.00% (ø) 0 0 0

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/temporalio/temporal-auto-scaled-workers/wci/workflow/compute_provider/aws_agentcore_test.go

// Instead we combine this agentCoreMaxRuntime timeout with an HTTP trace giving us confidence that the invocation was
// triggered. This is similar to Lambda's async invoke, we aren't concerned with the runtime operating successfully
// beyond invocation. This timeout is the max time we'll wait for any runtime invocation.
var agentCoreMaxRuntime = 5 * time.Second

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Does this feel any aggressive? Also, a noob question, why does this not meet the bar to be a config that can be changed at runtime? :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is a bit aggressive. The only way this really becomes a problem is if the invoke call from Temporal server to AWS takes 5s before sending the request, which shouldn't be the case and usually would be transient. The activity here would retry and hopefully succeed. I'm not completely opposed to making configurable server-side (not WDV/user configurable), but I'm not sure it's worth it.

@justinschoeff
justinschoeff merged commit 0a3927b into main Sep 16, 2026
9 checks passed
@justinschoeff
justinschoeff deleted the schoeff/agentcore-fix branch September 16, 2026 21:37
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.

4 participants