-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add Custom Engine with local transport #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zpzjzj
wants to merge
3
commits into
main
Choose a base branch
from
feat/custom-engine-local
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| //go:build e2e | ||
|
|
||
| package e2e | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "runtime" | ||
| "strings" | ||
| "testing" | ||
| "time" | ||
| ) | ||
|
|
||
| // getCustomEngineTestdataDir returns the path to e2e/testdata/custom-engine. | ||
| func getCustomEngineTestdataDir() string { | ||
| _, testFile, _, _ := runtime.Caller(0) | ||
| projectRoot := filepath.Dir(filepath.Dir(testFile)) | ||
| return filepath.Join(projectRoot, "e2e", "testdata", "custom-engine") | ||
| } | ||
|
|
||
| // skipIfNoPOSIXShell skips the test on platforms where the agent.sh fixture | ||
| // cannot run. agent.sh uses bash with `set -euo pipefail` and is not portable | ||
| // to Windows; the test infrastructure for cross-platform fixtures is tracked | ||
| // in issue #54. | ||
| func skipIfNoPOSIXShell(t *testing.T) { | ||
| t.Helper() | ||
| if runtime.GOOS == "windows" { | ||
| t.Skip("agent.sh fixture is POSIX-only; see issue #54") | ||
| } | ||
| } | ||
|
|
||
| // customEngineEnv returns an env slice that points the custom engine's | ||
| // ${CUSTOM_AGENT_BIN} placeholder at the fixture's agent.sh, while | ||
| // preserving PATH and HOME so the test still resolves system tools. | ||
| func customEngineEnv(agentBin string) []string { | ||
| return []string{ | ||
| "PATH=" + os.Getenv("PATH"), | ||
| "HOME=" + os.Getenv("HOME"), | ||
| "CUSTOM_AGENT_BIN=" + agentBin, | ||
| } | ||
| } | ||
|
|
||
| // TestPipeline_CustomEngine_LocalTransport runs the entire evaluation pipeline | ||
| // against a user-defined Custom Engine (transport: local). It verifies that: | ||
| // 1. The eval loads and the custom engine block is env-resolved and validated. | ||
| // 2. The framework writes the SessionInput JSON to ${input_file}. | ||
| // 3. The agent's stdout is parsed back into a SessionResult. | ||
| // 4. final_message reaches the report and an expect.must_contain rule passes. | ||
| func TestPipeline_CustomEngine_LocalTransport(t *testing.T) { | ||
| skipIfNoPOSIXShell(t) | ||
| t.Parallel() | ||
|
|
||
| dir := getCustomEngineTestdataDir() | ||
| evalPath := filepath.Join(dir, "evals", "eval.yaml") | ||
| agentBin := filepath.Join(dir, "agent.sh") | ||
|
|
||
| outputDir := t.TempDir() | ||
| result := Run(t, RunConfig{ | ||
| Env: customEngineEnv(agentBin), | ||
| WorkDir: dir, | ||
| Timeout: 60 * time.Second, | ||
| }, "run", evalPath, "--no-delete", "--output-dir", outputDir) | ||
|
|
||
| if result.ExitCode != 0 { | ||
| t.Fatalf("custom engine run failed: exit=%d\nstdout:\n%s\nstderr:\n%s", | ||
| result.ExitCode, result.Stdout, result.Stderr) | ||
| } | ||
| if !strings.Contains(result.Stdout, "Running evaluation") { | ||
| t.Errorf("expected runner stage log in output, got:\n%s", result.Stdout) | ||
| } | ||
| if !strings.Contains(result.Stdout, "PASS") { | ||
| t.Errorf("expected at least one PASS case, got:\n%s", result.Stdout) | ||
| } | ||
| if !strings.Contains(result.Stdout, "1 passed") { | ||
| t.Errorf("expected the summary line to report 1 passed, got:\n%s", result.Stdout) | ||
| } | ||
| } | ||
|
|
||
| // TestPipeline_CustomEngine_Validate runs `skill-up validate` against the | ||
| // custom engine eval.yaml. This exercises the post-load | ||
| // config.ResolveCustomEngineConfig path that validate.go invokes, including | ||
| // env-variable resolution of ${CUSTOM_AGENT_BIN}. | ||
| func TestPipeline_CustomEngine_Validate(t *testing.T) { | ||
| skipIfNoPOSIXShell(t) | ||
| t.Parallel() | ||
|
|
||
| dir := getCustomEngineTestdataDir() | ||
| evalPath := filepath.Join(dir, "evals", "eval.yaml") | ||
| agentBin := filepath.Join(dir, "agent.sh") | ||
|
|
||
| result := Run(t, RunConfig{ | ||
| Env: customEngineEnv(agentBin), | ||
| WorkDir: dir, | ||
| Timeout: 30 * time.Second, | ||
| }, "validate", evalPath) | ||
|
|
||
| if result.ExitCode != 0 { | ||
| t.Fatalf("validate failed: exit=%d\nstdout:\n%s\nstderr:\n%s", | ||
| result.ExitCode, result.Stdout, result.Stderr) | ||
| } | ||
| if !strings.Contains(result.Stdout, "is valid") { | ||
| t.Errorf("expected validation success message, got:\n%s", result.Stdout) | ||
| } | ||
| } | ||
|
|
||
| // TestPipeline_CustomEngine_RejectsMissingEnvVar verifies the load-time env | ||
| // resolution: when ${CUSTOM_AGENT_BIN} is unset, `run` must fail with a | ||
| // configuration error before exec'ing anything. | ||
| func TestPipeline_CustomEngine_RejectsMissingEnvVar(t *testing.T) { | ||
| skipIfNoPOSIXShell(t) | ||
| t.Parallel() | ||
|
|
||
| dir := getCustomEngineTestdataDir() | ||
| evalPath := filepath.Join(dir, "evals", "eval.yaml") | ||
|
|
||
| // Note: CUSTOM_AGENT_BIN intentionally unset. | ||
| result := Run(t, RunConfig{ | ||
| Env: []string{ | ||
| "PATH=" + os.Getenv("PATH"), | ||
| "HOME=" + os.Getenv("HOME"), | ||
| }, | ||
| WorkDir: dir, | ||
| Timeout: 30 * time.Second, | ||
| }, "run", evalPath, "--no-delete", "--output-dir", t.TempDir()) | ||
|
|
||
| if result.ExitCode == 0 { | ||
| t.Fatalf("expected run to fail with missing env var, got exit 0\nstdout:\n%s", result.Stdout) | ||
| } | ||
| combined := result.Stdout + result.Stderr | ||
| if !strings.Contains(combined, "CUSTOM_AGENT_BIN") { | ||
| t.Errorf("expected the error to name the missing env var, got:\n%s", combined) | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Custom Engine e2e fixture | ||
|
|
||
| This directory is a minimal skill-up fixture that exercises the **Custom | ||
| Engine** local transport end-to-end. It is consumed by `e2e/custom_engine_test.go`. | ||
|
|
||
| `agent.sh` is a deterministic stand-in for a real custom agent: it reads the | ||
| `SessionInput` JSON the framework writes to `${input_file}` and emits a fixed | ||
| `SessionResult` on stdout. The case asserts that `final_message` flows from | ||
| the agent's stdout into the report. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/bin/bash | ||
| # custom-engine/agent.sh — a deterministic mock for the Custom Engine local | ||
| # transport. The agent receives the SessionInput JSON path as its first arg | ||
| # (per the eval.yaml in this directory) and emits a SessionResult on stdout. | ||
| # | ||
| # The script intentionally ignores the input content and returns a fixed | ||
| # response so the e2e test is deterministic. It still verifies that the | ||
| # framework actually wrote the input file at the configured path, which is the | ||
| # main piece of the transport contract this test exercises. | ||
| set -euo pipefail | ||
|
|
||
| INPUT_FILE="${1:-}" | ||
| if [[ -z "$INPUT_FILE" || ! -f "$INPUT_FILE" ]]; then | ||
| echo "agent.sh: SessionInput file not provided or missing (got: '${INPUT_FILE:-}')" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| cat <<'JSON' | ||
| { | ||
| "exit_code": 0, | ||
| "final_message": "custom-engine-handled", | ||
| "turns": 1, | ||
| "transcript": [ | ||
| {"role": "user", "content": "ping"}, | ||
| {"role": "assistant", "content": "custom-engine-handled"} | ||
| ] | ||
| } | ||
| JSON |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| id: hello | ||
| title: Custom engine emits expected final_message | ||
| input: | ||
| prompt: ping the custom engine | ||
| expect: | ||
| must_contain: | ||
| - "custom-engine-handled" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| schema_version: v1alpha1 | ||
|
|
||
| environment: | ||
| type: none | ||
|
|
||
| mcp: | ||
| servers: [] | ||
|
|
||
| engine: | ||
| name: e2e-custom-agent | ||
| custom: | ||
| transport: local | ||
| response_format: session_result | ||
| local: | ||
| command: ${CUSTOM_AGENT_BIN} | ||
| args: | ||
| - ${input_file} | ||
|
|
||
| cases: | ||
| files: | ||
| - evals/cases/hello.yaml | ||
| defaults: | ||
| timeout_seconds: 60 | ||
| max_turns: 3 | ||
| parallelism: 1 | ||
|
|
||
| report: | ||
| formats: [json] |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.