refactor(custom-engine): extract customTransport interface with localTransport (#51)#88
Merged
Merged
Conversation
…Transport (#51) Introduce an internal `customTransport` seam in the agent package so a future HTTP transport drops in without rewriting the local-transport logic. `CustomAgent.Run` now does three transport-agnostic steps: `selectTransport` (local vs the http not-yet-implemented stub), `prepareRun` (build the timeout, template vars, and SessionInput), and `assembleResult` (map the outcome to a SessionResult with the shared exit-code/error semantics). The local-specific work — resolving I/O files, persisting the input, clearing a stale output, building+executing the command, and reading the result payload — moves behind `localTransport.run` in custom_local.go, which returns a uniform `transportOutcome`. Behavior-preserving: - Setup errors (pre-exec) still return errorResult(0); exec-phase failures are carried in transportOutcome.execErr so a partial result is still assembled, including the post-timeout fresh-context output read. - transportOutcome keeps `raw` and `stdout` distinct so a bookkeeping output_file is never graded as a text-format answer. - Framework input/output file registration keeps the "input always, output iff produced-or-cleared" rule; registerFrameworkIO becomes appendFrameworkFiles (no flag parameter, so the revive suppression is dropped). - The http transport still returns the exact "not yet implemented" error. All internal/agent tests are unchanged and pass (the safety net); make test, make verify (0 issues), and the e2e custom-engine suite are green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Summary
Resolves #51. Introduces an internal
customTransportinterface seam in the agent package so the planned HTTP transport (Phase 2) can drop in without rewriting the local-transport logic or the shared result handling. Pure refactor — no behavior, config, contract, or CLI change.What changed
CustomAgent.Runnow does three transport-agnostic steps and dispatches the rest:selectTransport— mapsengine.custom.transportto an implementation (localTransport, or thehttpnot-yet-implemented stub). HTTP later just returns&httpTransport{}from this one switch.prepareRun— builds the effective timeout, the full template variable set, and the marshaledSessionInputinto acustomRunPrep.assembleResult— maps atransportOutcometo aSessionResult, applying the shared exit-code / error semantics.The local-specific work — resolving I/O files, persisting the input, clearing a stale output, building+executing the command, and reading the result payload from
output_fileor stdout — moves behindlocalTransport.runin the newinternal/agent/custom_local.go, which returns a uniformtransportOutcome.runLocal/finishLocal/localRunContextare removed;registerFrameworkIO(bool flag-param) becomesappendFrameworkFiles([]string).Behavior-preserving (verified)
errorResult(0); exec-phase failures are carried intransportOutcome.execErrso a partial result is still assembled — including the post-timeout fresh-context output read.rawvsstdoutkept distinct so a bookkeepingoutput_fileis never graded as atext-format answer.httptransport still returns the exactcustom engine http transport is not yet implementederror.Test plan
make test(go test -race ./...) — all green;internal/agent/custom_test.go(~50TestCustomAgent_RunLocal_*) unchanged and passing (the safety net).make verify(fmt + vet + revive + golangci-lint) — 0 issues.make e2ecustom-engine suite —TestPipeline_CustomEngine_{LocalTransport,Validate,RejectsMissingEnvVar}all pass.Notes for reviewers
customenginepackage + unify token parsers) and Custom Engine: extract agent-specific metadata out of generic ExecOptions #49 (move case metadata out of genericExecOptions) remain open and are independent of this seam.🤖 Generated with Claude Code