Skip to content

Create Sessions through one use case - #555

Merged
SaladDay merged 1 commit into
aos/cutoverfrom
aos/t6c-session-creation
Oct 8, 2026
Merged

SaladDay merged 1 commit into
aos/cutoverfrom
aos/t6c-session-creation

Conversation

@SaladDay

@SaladDay SaladDay commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

POST /v1/agents/sessions no longer runs the creation flow inside the HTTP handler, and replay recovery happens in one place instead of six.

  • Use case. api/session_creation.go holds createSessionFrom and resolveSessionCreation, Handler methods with no HTTP types. They record the intent, look up a replay, resolve the template, saved Agent, model configuration, credentials and execution selection, validate, project, and choose admission or plain creation.
  • Handler. createSession decodes, calls the use case, and has one switch: error, stream, replay (reread plus audit), or created.
  • Errors. writeSessionCreationError is the single mapping. The configurationError marker keeps resolution-stage rejections as 400 unsupported_or_invalid_configuration. Template, Agent and Vault errors map by their domain; reader failures stay 500.
  • Replay. One lookup at entry, plus one at the single failure point after resolution, which preserves the guarantee that a concurrent creation that commits in between answers the retry. recoverSessionCreation and its six call sites are deleted.
  • Deleted validateSessionModelConfiguration. It repeated provider.ValidateConfiguration on the inputs resolveSessionExecution already validates.
  • Harness kinds now have one source, harnessconfig/builtin.

/v1 behaviour is unchanged. On base and head, a temporary differential test compared status, full error body, lookup count, creation path and audit rows for every stage's errors, and they were identical. A blind review repeated the comparison independently (60 requests through the router). One new lean test covers the second replay lookup; it fails when that lookup is removed.

Hand-written non-test code is net −6 lines.

Checks: go build, go vet ./services/core/..., go test for api, execution and sessions, the full integration package on a lane database (381 pass, 32 skipped for missing SDK or tools), check-names, and make check-openapi with no drift.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

createSession ran the whole creation flow inside the HTTP handler and
re-checked replay on six branches. createSessionFrom now owns the flow
without HTTP types: one replay lookup at entry, one more at the single
resolution failure point, then admission or plain creation. The handler
decodes, calls it, maps errors in one switch and writes the response.

A configurationError marks rejections of the resolved configuration so the
switch keeps the stage-dependent mapping. validateSessionModelConfiguration
repeated the provider check resolveSessionExecution already runs on the same
harness_config, so it is deleted. /v1 responses, error bodies, check order,
stream events and audit rows are unchanged.
@SaladDay
SaladDay merged commit d42bab3 into aos/cutover Oct 8, 2026
19 checks passed
@SaladDay
SaladDay deleted the aos/t6c-session-creation branch October 8, 2026 11:10
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