Repository navigation
chore: agentic OS polish — coding rules and reliability fixes - #26
Merged
Merged
Conversation
Project-level rules for Conventional Commits, minimal/typed/secure code, no UI churn, and targeted-only validation.
terminal_output returned a live session's full buffer (up to MAX_BUFFERED_CHARS) uncapped, unlike terminal_run/task_run/test_run which already tail-slice their own output. A long-running session could blow the context budget just from re-reading its output.
listDueAutomations only advances nextRunAt once finishAutomationRun completes, so an automation run that outlives one 30s poll tick was still "due" on the next tick and got dispatched a second time in parallel — same race let a manual runNow overlap a poll-triggered run. Add a process-local in-flight guard (mirrors knowledge-base.ts's inFlightSyncs) so a second concurrent dispatch is skipped instead of double-running.
Pre-existing tabs vs. the project's 2-space format — untouched until this PR's edit to buildTerminalOutputTool, at which point CI's --changed lint gate now checks the whole file. Whitespace-only, no behavior change.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
CLAUDE.md: persistent project-level AI coding rules (Conventional Commits, minimal/typed/secure code, no UI churn, targeted-only validation). A matching global~/.claude/CLAUDE.mdwas also installed in this environment (not part of this repo/diff).fix: truncate get_terminal_output before it enters model context—terminal_outputreturned a live terminal session's full buffer uncapped, unliketerminal_run/task_run/test_run, which already tail-slice to the last 4000/8000 chars. A long-running session's output could blow the model's context budget just from re-reading it. Now capped to the last 8000 chars, matching the existing pattern.fix: prevent duplicate concurrent runs of the same automation—listDueAutomationsonly advancesnextRunAtonce the run fully completes, so an automation run that outlives one 30s scheduler poll tick was still "due" on the next tick and got dispatched a second time in parallel (same race let a manualrunNowoverlap a poll-triggered run). Added a process-local in-flight guard, mirroring the existinginFlightSyncspattern inknowledge-base.ts, so a second concurrent dispatch is skipped instead of double-running the automation's agent/workflow.Investigated but found already well-handled (no change needed): knowledge-base prompt-context injection already has a char budget + env-configurable caps;
text_search/codebase_search/usagesalready cap aggregate output bytes; dead-letter/transient-retry handling and stale-run lease recovery already exist inagent-runtime.ts/scheduler.ts; approval resolution already uses an atomic CAS to prevent double-approval.Files changed
CLAUDE.md(new)apps/server/src/tools-builtin/read.tsapps/server/src/tools-builtin/read.test.ts(new)apps/server/src/scheduler.tsapps/server/src/scheduler.test.tsTest plan
bun test apps/server/src/tools-builtin/read.test.ts apps/server/src/tools-builtin/search.test.ts— passbun test apps/server/src/scheduler.test.ts— pass (5/5, including the new in-flight-guard test)bunx turbo run typecheck --filter=./apps/server— passbunx biome checkon all touched files — cleanRemaining risks
get_terminal_output's new cap is a fixed 8000 chars (matching the existingtask_run/test_runtail-slice constant); no configurability was added, consistent with "prefer simple truncation over complex summarization."Generated by Claude Code