Skip to content

Fix viewer analyze and Docker regressions after fork merge - #15

Open
Messimeimei wants to merge 91 commits into
openBitFun:devfrom
Messimeimei:fix/post-cherry-pick-regressions
Open

Fix viewer analyze and Docker regressions after fork merge#15
Messimeimei wants to merge 91 commits into
openBitFun:devfrom
Messimeimei:fix/post-cherry-pick-regressions

Conversation

@Messimeimei

@Messimeimei Messimeimei commented Jul 10, 2026

Copy link
Copy Markdown

Summary

  • Restore upstream docker.py and re-apply Windows agent setup in base.py, fixing harbor run failures (COMPOSE_BASE_PATH import error) after cherry-pick conflict resolution.
  • Fix viewer analyze/summarize: handle AggregateTransportError as 422, and update summarize tests for multi-provider analyze.
  • Align stale fork-only unit tests with upstream (OpenCode, Codex MCP env isolation).
  • Fix hello-world Docker image TLS (ca-certificates) and add scripts/render-bitfun-hello-world-job.py for running bitfun-cli on hello-world from .env credentials.

Test plan

  • uv run pytest tests/unit/ — 4874 passed
  • uv run harbor run -p examples/tasks/hello-world -a oracle -e docker -y — Mean 1.000
  • uv run harbor run -c /tmp/bitfun-hello-world.yaml -y (rendered via scripts/render-bitfun-hello-world-job.py) — Mean 1.000

JinnanDuan and others added 30 commits July 8, 2026 17:56
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Specifies how `populate_context_post_run` in the existing `bitfun-cli`
Harbor agent should convert BitFun's native session/trace/metrics data
into ATIF v1.7 trajectories, following the `claude_code.py` pattern
(_get_session_dir / _convert_events_to_trajectory) while using a
cp-back finally block (Codex-style) since BitFun has no env-var knob
to redirect its data directory to the harbor mount.

Co-authored-by: Cursor <cursoragent@cursor.com>
Concrete 16-task TDD plan for the design captured in
docs/superpowers/specs/2026-05-13-bitfun-cli-atif-adapter-design.md:
SUPPORTS_ATIF, session-dir discovery, turn/round normalization
(text/thinking/tool), nearest-timestamp token allocation, LiteLLM
costing, ATIF v1.7 subagent embedding, populate_context_post_run,
container-side cp-back, and a golden integration fixture.

Co-authored-by: Cursor <cursoragent@cursor.com>
Convert BitFun session/token artifacts under logs_dir/bitfun/ into ATIF
trajectories, populate AgentContext, and copy container-side artifacts back
after exec. Include unit coverage and a golden fixture for end-to-end JSON
shape. Document ATIF support in AGENTS.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ncated

BitFun CLI 0.2.7's `exec` mode only writes a synthetic `-final-round`
placeholder to `turns/turn-*.json` (with empty `toolItems` and
`metadata.toolCallCount: 0`), losing all intermediate tool calls and
thinking blocks. The full conversation is still preserved in
`snapshots/context-NNNN.json`.

Add `_synthesize_turns_from_snapshot()` to reconstruct turn-shaped data
from snapshot messages (grouped by `turn_id` / `round_id`) and
`_load_turns_preferring_snapshot()` to pick whichever source has more
rounds. Turn files keep priority on ties so their richer metadata
(`durationMs`, subagent fields) is preserved.

On a real broken session this lifts the trajectory from 2 steps / 0
tool calls to 80 steps / 42 tool calls, matching the BitFun runtime
log (`rounds=40, total_tools=42`).

Co-authored-by: Cursor <cursoragent@cursor.com>
Let Harbor Viewer job/trial Analyze use multiple Anthropic-compatible
providers (direct API, corporate proxy, etc.) without hard-coding a
single model list.

- Add TOML profile loader (harbor.analyze.profiles) with built-in
  Anthropic fallback; secrets stay in process env via api_key_env /
  base_url_env, not in the config file
- Expose GET /api/analyze/profiles; extend summarize POST to accept
  profile_id + model_id while keeping legacy model field
- Inject per-request SDK env overlay in Analyzer/query_agent so
  credentials are not written to global os.environ
- Add harbor view --analyze-profiles and HARBOR_ANALYZE_PROFILES for
  production and dev reload workers
- Update Viewer UI with Profile + Model pickers when profiles are
  available; fall back to Haiku/Sonnet/Opus on fetch errors
- Add examples/config docs, example TOML, and unit tests

Co-authored-by: Cursor <cursoragent@cursor.com>
Document argv/stdin/Read fallback for large job-level analyze prompts and the approved design for implementation.

Co-authored-by: Cursor <cursoragent@cursor.com>
TDD implementation plan for argv/stdin/Read fallback and Viewer 422 errors.

Co-authored-by: Cursor <cursoragent@cursor.com>
Route oversized aggregation prompts via stdin and agent Read when argv
limits are exceeded; surface AggregateTransportError as Viewer 422.

Co-authored-by: Cursor <cursoragent@cursor.com>
Provide root-level one-case and all-cases YAML configs so bitfun-cli Docker runs can be started with harbor run -c.

Co-authored-by: Cursor <cursoragent@cursor.com>
Capture approved design for mkdir/pipeline exit-code handling, failure
log persistence, cp-back observability, and env consistency.

Co-authored-by: Cursor <cursoragent@cursor.com>
Task-by-task TDD plan covering run shell, failure log persist,
env merge, _exec override, and cp-back gap logging.

Co-authored-by: Cursor <cursoragent@cursor.com>
Ensure /logs/agent exists before tee, return bitfun-cli exit via PIPESTATUS,
persist exec output to trial agent/bitfun.txt on failure, merge config agent
env into run/cp-back, and log missing cp-back artifacts.

Co-authored-by: Cursor <cursoragent@cursor.com>
SWE-bench Pro images use WORKDIR /app, so forcing /testbed caused docker exec chdir failures on agent run.

Co-authored-by: Cursor <cursoragent@cursor.com>
Preserve BitFun latency and output tokens-per-second in ATIF metrics.extra
and surface summary and step-level TPS in Harbor view.

Co-authored-by: Cursor <cursoragent@cursor.com>
The summary TPS builder filtered out subagent records, which was dead
code for main trajectories (already filtered upstream) but blanked all
summary TPS for subagent trajectories even though their step-level TPS
was still computed. Iterate over the trajectory's own records instead so
subagent summaries get TPS consistently.

Also round completion_tokens_per_second to 2 decimals before persisting,
and document the end-to-end-latency TPS semantics and the deliberate
step-vs-summary key naming difference.

Update the bitfun golden fixture so the subagent final_metrics carry the
missing_latency marker.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 39d0230f-3a77-430b-ad7a-beef44881255

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Install ca-certificates in the hello-world Docker image so bitfun-cli can call HTTPS APIs from trials, and add a script to render a Harbor job config from .env credentials.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants