Skip to content

feat: Decouple ExecutionResponse from Copilot SDK event types (#10)#390

Closed
spboyer wants to merge 1 commit into
mainfrom
spboyer-decouple-execution-response
Closed

feat: Decouple ExecutionResponse from Copilot SDK event types (#10)#390
spboyer wants to merge 1 commit into
mainfrom
spboyer-decouple-execution-response

Conversation

@spboyer

@spboyer spboyer commented Jun 28, 2026

Copy link
Copy Markdown
Member

Summary

Phase 1 of #10. Decouples waza's execution surface from copilot.SessionEvent so future engines can populate ExecutionResponse.Events without depending on the Copilot SDK's event types. Phase 2 (multi-engine implementations, fully neutral ToolExecutionCompleteResult) is intentionally out of scope.

Changes

  • New package internal/agentevents — neutral Event struct, EventType constants, and 21 typed payload structs (AssistantMessageData, ToolExecutionStartData, ToolExecutionCompleteData, etc.) that mirror the SDK shape.
  • New adapter internal/execution/agentevents_adapter.goFromCopilotEvent(copilot.SessionEvent) agentevents.Event is applied inside SessionEventsCollector.On so the SDK callback contract is preserved at the engine boundary while everything downstream is neutral.
  • ExecutionResponse.Events []agentevents.Event and SessionEventsCollector.SessionEvents() now return neutral events.
  • models.TranscriptEvent embeds agentevents.Event (the embedded field was renamed SessionEventEvent). JSON wire format is preserved: each EventType constant has the same string value as its copilot.SessionEventType counterpart (e.g. "assistant.message", "tool.execution_complete").
  • Consumers migrated to neutral types: internal/transcript, internal/orchestration runner, internal/graders/inline_script_grader, internal/webapi/store, and cmd/waza/cmd_run_suggest.
  • Tests updated to construct neutral events and assert against neutral EventType constants. SDK-boundary tests still feed copilot.SessionEvent into On(...) as that's the SDK callback contract.

Phase 1 residual coupling (documented; Phase 2)

  • agentevents.ToolExecutionCompleteData.Result and models.ToolCall.Result remain *copilot.ToolExecutionCompleteResult so the dashboard payload (Content, DetailedContent, Contents, BinaryResultsForLlm) is wire-compatible bit-for-bit.
  • internal/copilotevents and internal/utils/logging.go keep their SDK imports — they sit on the SDK side of the boundary.

Verification

  • go build ./... — clean
  • go test ./... — passes (the only failure is internal/models/TestLoadEvalSpec_MCPMocksRequireSchemaVersion11, which is pre-existing on main ec8cb62 and unrelated to this change).
  • golangci-lint run — 0 issues.

Closes #10 (Phase 1 only)

Phase 1 of #10: introduce a provider-neutral event model so waza's
execution surface (ExecutionResponse.Events, transcripts, grader
contexts, web API payloads) no longer depends on copilot-sdk's
SessionEvent types.

Changes:
- New package internal/agentevents with neutral Event, EventType
  constants, and 21 typed payload structs that mirror the SDK shape.
- New adapter internal/execution/agentevents_adapter.go
  (FromCopilotEvent) that converts copilot.SessionEvent into the
  neutral type at the SessionEventsCollector.On boundary.
- ExecutionResponse.Events now []agentevents.Event; collector.SessionEvents()
  returns neutral events.
- models.TranscriptEvent embeds agentevents.Event (field renamed
  SessionEvent -> Event). JSON wire format preserved: EventType
  constants are string-literal-identical to the SDK values.
- Refactored consumers to neutral types: transcript builder,
  orchestration runner, inline-script grader, webapi store, and the
  cmd/waza run/suggest path.
- Tests updated to construct neutral events and assert against neutral
  EventType constants.

Phase 1 residual coupling (documented; addressed in Phase 2):
agentevents.ToolExecutionCompleteData.Result and models.ToolCall.Result
remain *copilot.ToolExecutionCompleteResult to keep the dashboard
payload wire format bit-for-bit identical.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 28, 2026 13:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR implements Phase 1 of issue #10 by decoupling execution.ExecutionResponse.Events (and downstream transcript/web consumers) from Copilot SDK copilot.SessionEvent types. It introduces a provider-neutral event model (internal/agentevents) and adapts Copilot SDK events at the engine boundary, keeping existing JSON transcript/dashboard wire formats consistent while enabling future non-Copilot engines.

Changes:

  • Introduces internal/agentevents as the neutral event model (event type constants + typed payloads + accessor helpers).
  • Adapts Copilot SDK events to neutral events at the boundary via execution.FromCopilotEvent(...), and migrates ExecutionResponse.Events + transcript plumbing to use neutral events.
  • Updates key consumers (orchestration, graders, web API, suggest flow) and adjusts tests to construct/assert against neutral event types.
Show a summary per file
File Description
internal/agentevents/events.go Adds provider-neutral Event/EventType model, payload structs, and accessor helpers.
internal/execution/agentevents_adapter.go Converts Copilot SDK SessionEvent payloads into neutral agentevents.Event at the boundary.
internal/execution/session_events_collector.go Stores neutral events internally while preserving the SDK callback signature for On(...).
internal/execution/engine.go Switches ExecutionResponse.Events and message extraction to neutral event types/helpers.
internal/execution/mock.go Updates mock engine response to return neutral events.
internal/models/events.go Embeds neutral events in TranscriptEvent and updates transcript marshal/unmarshal + tool-call correlation.
internal/transcript/transcript.go Updates transcript builder to wrap neutral events into models.TranscriptEvent.
internal/orchestration/runner.go Updates transcript building to embed neutral events.
internal/webapi/store.go Migrates transcript event mapping to use agentevents helpers.
cmd/waza/cmd_run_suggest.go Migrates suggestion trace extraction to use neutral event types/helpers.
internal/webapi/additional_test.go Updates tests to construct neutral events in transcripts.
internal/transcript/transcript_test.go Updates transcript tests to use neutral events.
internal/orchestration/runner_orchestration_test.go Updates orchestration tests to use neutral event types/constants.
internal/models/events_test.go Updates transcript JSON round-trip tests for neutral event payload types.
internal/graders/inline_script_grader.go Updates grader transcript/tool-call extraction to operate on neutral events.
internal/graders/inline_script_grader_test.go Updates grader tests to use neutral events and collector output.
internal/execution/engine_response_test.go Updates message-extraction test to use neutral events.
cmd/waza/cmd_run_suggest_test.go Updates suggest tests to use neutral events.

Review details

  • Files reviewed: 18/18 changed files
  • Comments generated: 2
  • Review effort level: Low

Comment thread internal/models/events.go
Comment on lines +127 to +130
case agentevents.EventTypeAssistantMessage:
return &agentevents.AssistantMessageData{Content: derefString(content)}
case agentevents.EventTypeAssistantMessageDelta:
return &agentevents.AssistantMessageDeltaData{DeltaContent: derefString(content)}
Comment thread internal/models/events.go
Comment on lines +145 to +146
case agentevents.EventTypeSessionError:
return &agentevents.SessionErrorData{Message: derefString(message)}
@spboyer

spboyer commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

Closing in favor of #396 (smaller, green CI, latest iteration of this Phase-1 refactor).

@spboyer spboyer closed this Jun 30, 2026
@spboyer spboyer deleted the spboyer-decouple-execution-response branch June 30, 2026 14:13
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.

[E1] Decouple ExecutionResponse from Copilot SDK + Multi-Agent Engine Support

3 participants