Skip to content
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions verifiers/v1/harnesses/bash/harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import os
from pathlib import Path

from pydantic import PositiveInt
from pydantic_config import BaseConfig

from verifiers.v1.clients import ModelContext
from verifiers.v1.configs.harness import HarnessConfig
from verifiers.v1.dialects.chat import message_to_wire
Expand All @@ -27,6 +30,14 @@
)


class CompactionConfig(BaseConfig):
"""Context compaction policy for the bash agent loop."""

summarize_at_tokens: PositiveInt | None = None
"""Compact at this token count. When unset, compact when 16k tokens remain below the
model context window when the provider advertises it."""


class BashHarnessConfig(HarnessConfig):
edit: bool = True
"""Offer the local `edit` tool (single-occurrence string replacement in a file) alongside
Expand All @@ -37,6 +48,9 @@ class BashHarnessConfig(HarnessConfig):
eval environment; the key is handed to the program over argv (like the interception secret) so
the agent's `bash` subprocesses don't inherit it."""

compaction: CompactionConfig | None = None
"""Context compaction policy. Set an empty config to use automatic thresholds."""


class BashHarness(Harness[BashHarnessConfig]):
APPENDS_SYSTEM_PROMPT = True
Expand Down Expand Up @@ -77,6 +91,11 @@ async def launch(
]
if tool_interception_url:
args.append(f"--tool-interception-url={tool_interception_url}")
if self.config.compaction is not None:
args.append("--compaction")
threshold = self.config.compaction.summarize_at_tokens
if threshold is not None:
args.append(f"--summarize-at-tokens={threshold}")
if self.config.edit:
args.append("--edit")
if self.config.search:
Expand Down
Loading
Loading