agentfield icon indicating copy to clipboard operation
agentfield copied to clipboard

[Go SDK] Add tests for harness providers (claim one file if you want)

Open santoshkumarradha opened this issue 7 months ago • 8 comments

Test coverage: Go SDK harness/ — factory, cli, result, provider, providers

The harness package has a factory, CLI wrapper, result struct, options helpers, and four provider implementations (claudecode, codex, gemini, opencode). Four of these providers follow the same shape. Bundled into one issue because the testing patterns share infrastructure.

Scope

New test files:

  • sdk/go/harness/factory_test.go
  • sdk/go/harness/cli_test.go
  • sdk/go/harness/result_test.go
  • sdk/go/harness/provider_test.go
  • sdk/go/harness/claudecode_test.go
  • sdk/go/harness/opencode_test.go
  • sdk/go/harness/gemini_test.go
  • sdk/go/harness/codex_test.go

Test cases

factory.go / BuildProvider:

  • BuildProvider("opencode", "path") returns *OpenCodeProvider
  • BuildProvider("claude-code", "path") returns *ClaudeCodeProvider
  • BuildProvider("unknown", "") returns a helpful error

cli.go:

  • RunCLI executes a basic command (echo) and captures stdout
  • RunCLI correctly merges env vars (and unsets when value is empty)
  • RunCLI respects context cancellation / timeout
  • StripANSI removes complex escape sequences
  • isExecNotFound identifies "executable file not found" errors

result.go:

  • (r *Result) Text() returns the raw result string
  • Various FailureType values produce consistent serialization

provider.go / Options:

  • maxRetries() returns set value or default (3)
  • timeout() returns set value or default (600)
  • Each default/override path covered

claudecode.go / opencode.go / gemini.go / codex.go .Execute:

  • Constructs correct CLI flags per provider (model, max-turns, etc.)
  • Parses session metrics from provider output
  • Handles binary-not-found gracefully
  • Captures stdout as result; handles non-zero exit codes

Fixture / mock boundary

  • Real exec.Command with short shell scripts (sh -c 'echo ...') for RunCLI
  • Mock claude / codex / gemini / opencode binaries via tiny shell scripts in t.TempDir()
  • Table-driven subtests

Acceptance criteria

  • [ ] All 8 test files added
  • [ ] go test ./sdk/go/harness/... passes
  • [ ] Coverage on sdk/go/harness ≥80%

Claim one or all: this issue is contributor-friendly to split — feel free to claim just one file (factory_test.go is the easiest entry point) and leave the rest for others.

Size: L · Difficulty: intermediate · Language: Go


Part of epic #387 — parent tracker.


How to work on this

Setup

git clone https://github.com/Agent-Field/agentfield.git
cd agentfield
make install        # installs Go, Python (via uv), and Node deps
make build          # optional — builds the control plane binary

Run the baseline test suite

Before you change anything, run the tests for the language this issue targets so you know what "green" looks like:

  • Go control plane: cd control-plane && go test ./... -count=1
  • Go SDK: cd sdk/go && go test ./... -count=1
  • Python SDK: cd sdk/python && uv run pytest -q
  • TypeScript SDK: cd sdk/typescript && bun test

Package coverage baseline (so you can show improvement in the PR):

  • go test -cover ./control-plane/internal/...
  • uv run pytest --cov=agentfield sdk/python/tests
  • bun test --coverage (TypeScript)

Using Claude Code or another AI coding agent

This repo has a CLAUDE.md at the root that Claude Code and compatible agents will read automatically. A working flow:

  1. cd into the repo and run claude (or open in your IDE's agent).
  2. Paste this issue URL and say: "Please implement this issue, following every acceptance-criteria checkbox. Do not change source files — only add tests under the target path in the issue. When you're done, run the test suite command from the issue and paste the result."
  3. Let the agent read existing tests in the same package as a model for style / fixtures — we point to them in the issue.
  4. Run make lint before opening the PR.

See the AI-Assisted Contributions guide for testing requirements. Tag your PR with ai-assisted if you used an AI agent.

Claiming this issue

Comment I'd like to work on this and a maintainer will assign it to you. If you're new to open source, issues labelled good first issue or first-timers-only are hand-picked for a smooth first PR — we'll guide you if you get stuck.

Opening the PR

  • Branch name: tests/<short-description> or refactor/<short-description>
  • Link this issue in the PR description with Closes #<number>
  • Paste the before/after test output or coverage delta in the PR body
  • Keep the diff to the scope in this issue — no drive-by cleanups

Help & questions

  • Comment on this issue — we monitor all assigned issues.
  • Join the community Discord: run /gsd-join-discord or check the README for the invite.
  • For repo-wide questions, open a discussion with the help tag.

santoshkumarradha avatar Apr 11 '26 18:04 santoshkumarradha

i already worked and created the opencode_test.go with that i like to contribute on sdk/go/harness/factory_test.go this file too.

dinzz005 avatar May 01 '26 16:05 dinzz005

Thanks for picking this up, @dinzz005! :tada:

Here's what to expect:

  • We'll check in after 7 days if we haven't heard an update
  • After 14 days, we'll send a second reminder
  • After 21 days without activity, we'll unassign to let others contribute

Tips for success:

  • Drop a comment when you start working on it
  • Share any blockers - we're here to help!
  • Link your PR with Fixes #404 in the description

Happy coding! :rocket:

github-actions[bot] avatar May 01 '26 16:05 github-actions[bot]

Hey @dinzz005! :wave:

Just a friendly reminder that you're assigned to this issue. It's been about a week since assignment.

How's it going? We'd love to hear:

  • Any progress updates?
  • Running into any blockers we can help with?
  • Need more time? (Totally fine!)

A quick comment helps us know you're still interested. If your plans have changed, no worries at all - just let us know and we can find another contributor.

Thanks for contributing to AgentField! :rocket:

github-actions[bot] avatar May 09 '26 09:05 github-actions[bot]

Hi @dinzz005,

Just checking in again! It's been 14 days since we last heard from you on this issue.

Quick options:

  • :speech_balloon: Drop a comment with a progress update
  • :link: Link a draft PR if you've started working on it
  • :wave: Let us know if you'd like to be unassigned (no judgment!)

If we don't hear back in 7 days, we'll unassign this issue to give other contributors a chance to help.

Thanks for understanding!

github-actions[bot] avatar May 16 '26 10:05 github-actions[bot]

Hi @dinzz005,

It's been 22 days since the last update on this issue. To keep the project moving, we've unassigned this issue so other contributors can pick it up.

No worries at all! Life happens, and we totally understand. If you'd like to continue working on this, just comment here and we'll reassign it to you.

This issue is now available for anyone who'd like to contribute. Check out our contribution guidelines if you're interested!

Thanks for your interest in AgentField! :heart:

github-actions[bot] avatar May 24 '26 10:05 github-actions[bot]

I'd like to work on sdk/go/harness/factory_test.go from this issue.

be-student avatar Sep 06 '26 06:09 be-student

I'd like to work on result_test.go

FriendlyPasser avatar Sep 07 '26 03:09 FriendlyPasser

Hi! I'd like to work on the sdk/go/harness/provider_test.go slice of this issue.

lyxnbclass avatar Sep 19 '26 13:09 lyxnbclass