Skip to content

[ark] Ark bash agent improvements#8140

Merged
dglazkov merged 1 commit intomainfrom
ark-bash-improvements
Mar 11, 2026
Merged

[ark] Ark bash agent improvements#8140
dglazkov merged 1 commit intomainfrom
ark-bash-improvements

Conversation

@dglazkov
Copy link
Collaborator

What

Several improvements to the Ark bash agent: configurable skillsets via allowlist, debug view upgrades, and graceful task cancellation on server shutdown.

Why

The bash agent was loading all skills indiscriminately, the debug view was trimming thoughts and hiding function call details, and background agent tasks survived server restarts/shutdowns.

Changes

Skill loading

  • [NEW] skill_loader.py — shared skill loader with load_skills(include=[...]) allowlist and copy_skills_to_work_dir(transform=...) for path rewriting
  • main.py — bash agent uses include=["teacher"], UI agent loads all skills
  • journey_router.py — delegates to shared loader
  • skilled_agent.py — added skills_dir parameter to run_skilled_agent and _build_skill_instruction so meta-instruction paths are caller-configurable (defaults to /mnt/skills)

Debug view (debug-bash.html)

  • Full thoughts (removed 200-char truncation)
  • Full bash output (removed 500-char truncation)
  • Function calls in collapsible <details>/<summary> twisties showing args and results
  • Non-bash function results now emitted (previously only bash stdout was shown)
  • Run list panel showing all out/* runs with objective, status, progress bar, and artifact links
  • Active work area (log) positioned above run list; newest runs shown first

Task lifecycle

  • Run.task field tracks the asyncio.Task handle
  • FastAPI lifespan shutdown handler cancels all running agent tasks
  • _run_bash_agent catches CancelledError and emits clean termination event
  • [NEW] test_shutdown.py — 3 tests for cancellation scenarios

Testing

  • pytest tests/ in spikes/ark/backend — 46 tests pass
  • Manual: run an agent, Ctrl+C the server, verify the task stops

## What
Several improvements to the Ark bash agent: configurable skillsets via allowlist, debug view upgrades, and graceful task cancellation on server shutdown.

## Why
The bash agent was loading all skills indiscriminately, the debug view was trimming thoughts and hiding function call details, and background agent tasks survived server restarts/shutdowns.

## Changes

### Skill loading
- **[NEW] `skill_loader.py`** — shared skill loader with `load_skills(include=[...])` allowlist and `copy_skills_to_work_dir(transform=...)` for path rewriting
- **`main.py`** — bash agent uses `include=["teacher"]`, UI agent loads all skills
- **`journey_router.py`** — delegates to shared loader
- **`skilled_agent.py`** — added `skills_dir` parameter to `run_skilled_agent` and `_build_skill_instruction` so meta-instruction paths are caller-configurable (defaults to `/mnt/skills`)

### Debug view (`debug-bash.html`)
- Full thoughts (removed 200-char truncation)
- Full bash output (removed 500-char truncation)
- Function calls in collapsible `<details>/<summary>` twisties showing args and results
- Non-bash function results now emitted (previously only bash stdout was shown)
- Run list panel showing all `out/*` runs with objective, status, progress bar, and artifact links
- Active work area (log) positioned above run list; newest runs shown first

### Task lifecycle
- `Run.task` field tracks the `asyncio.Task` handle
- FastAPI `lifespan` shutdown handler cancels all running agent tasks
- `_run_bash_agent` catches `CancelledError` and emits clean termination event
- **[NEW] `test_shutdown.py`** — 3 tests for cancellation scenarios

## Testing
- `pytest tests/` in `spikes/ark/backend` — 46 tests pass
- Manual: run an agent, Ctrl+C the server, verify the task stops
@dglazkov dglazkov enabled auto-merge (squash) March 11, 2026 20:50
@dglazkov dglazkov merged commit 4f962df into main Mar 11, 2026
3 checks passed
@dglazkov dglazkov deleted the ark-bash-improvements branch March 11, 2026 20:53
@github-actions
Copy link

📊 Coverage Report

Metric PR Main Delta
Lines 98.30% 98.30% ⚪ +0.00%
Functions 98.25% 98.25% ⚪ +0.00%
Branches 94.17% 94.17% ⚪ +0.00%

@dglazkov dglazkov restored the ark-bash-improvements branch March 11, 2026 20:59
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.

1 participant