Repository navigation
feat(extras): add AgentcoreSession.invoke - #972
Draft
ParidelPooya wants to merge 1 commit into
Draft
ParidelPooya wants to merge 1 commit into
ParidelPooya wants to merge 1 commit into
Conversation
AgentcoreSession is now a class, as MicrovmSession is. The session handler receives it instead of the private handle. invoke runs one job in a child context named after the job. It builds the job scope with _AgentcoreScope.create, so it checks the name, the timeouts and the input size before any durable operation. It runs the job with _run_job and a stop that does nothing. So a failed job leaves the session running, and the session stops after its handler. A job error leaves the job's child context as ChildContextError. invoke and agentcore_session restore an AgentCore error to its own class, as microvm_session does. Other handler errors stay ChildContextError. agentcore_session is now exported from compute.agentcore.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
AgentcoreSession.invoke(context, name, *, job_input, options)sends one job to the session and returns the job's result.Why
agentcore_sessioncreates and stops a session, but its handler cannot send a job yet. This change adds the job call.Change
AgentcoreSessionis now a concrete class, asMicrovmSessionis. The session handler receives it. The private_SessionHandleis removed.invokebuilds the job scope with_AgentcoreScope.create. It turns the session config and the job options into anAgentcoreConfig. So the name, timeout, heartbeat and input-size checks ofagentcore()run before any durable operation, without copied code.invokeruns the job with_run_joband a stop that does nothing. So a failed job leaves the session running. The session stops after its handler, as before.agentcore_sessionandAgentcoreSessionare exported fromcompute.agentcore.What I copied from
MicrovmSession.invoke:name, in thecontextpassed toinvoke. Its operations are<name>.callbackand<name>.request._run_job.invokeconverts the job'sChildContextErrorback to its AgentCore class withAgentcoreError.from_child_context_error.agentcore_sessionconverts aChildContextErrorback only when its cause is an AgentCore error, asmicrovm_sessiondoes. Every other handler error staysChildContextError.What I did not copy:
MicrovmSession.invokerefuses the outer context with aTypeError. That is a guard for a developer mistake, so it is left out. The sessiontimeoutfield is unchanged; #970 removes it. The session child context has no subtype yet; E7 (#945) adds it.Testing
mypy src tests: no issues.hatch fmt --checkandlintcommit.py: pass.runtimeSessionIdas the stop call, and each job has its own callback ID.AgentcoreJobFailedError,AgentcoreTimeoutErrororAgentcoreDeliveryError.MAX_JOB_INPUT_BYTESfails before any job operation.invokeerror conversion: 5 tests fail.agentcore_sessionerror conversion: test 3 fails.agentcore_sessionconversion for every error: 2 existing tests fail.Closes #944
Part of #954
Twin: aws/aws-durable-execution-sdk-js#1235