kheish
AGENTS.md227 starsChanged 5 months agoApache-2.0View on GitHub
This file is for future agent instances working inside kheish/. Read this first when you need to change code, run the daemon, validate behavior on real providers, or debug a broken session. This is an operational guide, not a full architecture spec. Repository root: - the directory that contains this AGENTS.md Important files: - .env - Cargo.toml - README.md - AGENTS.md Most active crates: - crates/kheish-daemon: daemon HTTP API, CLI integration, run/session/task control plane - crates/kheish-runtime: provider drivers, prompt building,…
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 33,398 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
37 rules. About 0 are common, 31 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈31
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 5
Read this first when you need to change code, run the daemon, validate behavior on real providers, or debug a broken session.
- Distinctive: line 11
Treat the daemon as the source of truth.
- Distinctive: line 12
Prefer the real CLI and HTTP API over direct inspection of JSON state files.
- Very specific: line 13
Use fresh --state-root values for real validation.
- Distinctive: line 14
Use fresh sessions for E2E tests.
- Distinctive: line 16
Keep examples and paths portable.
- Distinctive: line 17
When behavior differs across providers, keep the abstraction provider-neutral unless the provider wire format truly requires divergence.
- Distinctive: line 18
Do not infer product behavior from stale sessions created by an older daemon build.
- Distinctive: line 46
Do not assume the daemon you are talking to uses the state root you expect.
- Very specific: line 66
If you are testing OpenAI live, prefer an explicit model such as gpt-5.4.
- Very specific: line 127
If status or runtime get fails with a decode error such as a missing hooks field, the CLI and daemon are on different schema versions.
- Distinctive: line 146
If you want provider/model overrides on one run:
- Distinctive: line 185
Do not rely on implicit completion contracts inferred from the prompt.
- Distinctive: line 188
only explicit completion requirements are enforced
- Distinctive: line 191
Use explicit requirements only when you truly need a deterministic artifact contract:
- Distinctive: line 199
Do not use this for every file-producing task by reflex.
- Very specific: line 238
if runs wait appears stuck, check approvals before assuming the run is hung
- Distinctive: line 280
Use this when validating long-running shell behavior:
- Distinctive: line 284
stop the task and verify the terminal status
- Distinctive: line 313
After startup, inspect runtime:
- Distinctive: line 323
When debugging MCP, validate on both providers.
- Distinctive: line 349
Use hooks when validating:
- Distinctive: line 355
Do not assume hook behavior from unit tests alone.
- Distinctive: line 373
use it only on isolated daemon instances
- Very specific: line 417
Do not assume a specific profile has a tool.
- Distinctive: line 458
When a change touches the daemon behavior, also validate with the real binary:
- Distinctive: line 460
start an isolated daemon
- Distinctive: line 462
use a fresh session
- Distinctive: line 463
verify the final artifact or final answer directly
- Distinctive: line 465
Do this especially for:
- Very specific: line 509
Ask the agent to launch a long bash task in background, then inspect it with tasks list and tasks output.
- Distinctive: line 517
If decode errors mention missing fields, rebuild and restart the daemon or use a matching CLI.
- Distinctive: line 528
If it suddenly returns empty results, inspect the provider output and the search HTML before blaming the prompt.
- Distinctive: line 534
When a run looks wrong, prefer this order:
- Distinctive: line 607
If you need architecture detail, start with:
- Distinctive: line 610
If you need ground truth about behavior, trust:
- Distinctive: line 616
Use raw state files only as a fallback.
≈ “Common” is an estimate: at least 1 in 5 of the 43,423 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Kheish Operator Guide
This file is for future agent instances working inside kheish/.
Read this first when you need to change code, run the daemon, validate behavior on real providers, or debug a broken session.
This is an operational guide, not a full architecture spec.
Working Rules
- Treat the daemon as the source of truth.
- Prefer the real CLI and HTTP API over direct inspection of JSON state files.
- Use fresh
--state-rootvalues for real validation. - Use fresh sessions for E2E tests.
- Validate on the real daemon, not only with unit tests.
- Keep examples and paths portable. This repository may be cloned anywhere.
- When behavior differs across providers, keep the abstraction provider-neutral unless the provider wire format truly requires divergence.
- Do not infer product behavior from stale sessions created by an older daemon build.
Repository Basics
Repository root:
- the directory that contains this
AGENTS.md
Important files:
.envCargo.tomlREADME.mdAGENTS.md
Most active crates:
crates/kheish-daemon: daemon HTTP API, CLI integration, run/session/task control planecrates/kheish-runtime: provider drivers, prompt building, permissions, runtime assemblycrates/kheish-core: engine loop, compaction, hook integrationcrates/kheish-coding-tools: built-in tools such asread_file,write_file,bash,web_fetch,web_searchcrates/kheish-mcp: MCP loading, config import, tool/resource adaptationcrates/kheish-agent: agent orchestration, snapshots, sidechains, mailboxcrates/kheish-types: shared data contracts
Important old state roots that may still exist in this repo:
.kheish-daemon.kheish-daemon2.kheish-daemon-fix.kheish-daemon-fix2
Do not assume the daemon you are talking to uses the state root you expect. Always be explicit.
Environment
Load provider keys before live testing:
cd "$(git rev-parse --show-toplevel)"
set -a
source .env
set +aSupported providers in normal operation:
anthropicgoogleopenaiopenrouterxai
If you are testing OpenAI live, prefer an explicit model such as gpt-5.4. Some local defaults may reject options like temperature.
For route details, see docs/runtime/providers-and-routing.mdx.
Build
Normal build:
cd "$(git rev-parse --show-toplevel)"
cargo build -p kheish-daemonFast sanity build:
cargo b -p kheish-daemonDaemon binary:
target/debug/kheish-daemon
Start the Daemon
Canonical isolated start:
cd "$(git rev-parse --show-toplevel)"
set -a
source .env
set +a
mkdir -p ./.kheish-workspace-test
./target/debug/kheish-daemon serve \
--bind 127.0.0.1:4000 \
--state-root .kheish-daemon-test \
--workspace-root ./.kheish-workspace-testServe options you will use often:
--provider anthropic|openai--model ...--api-key ...--workspace-root ...--state-root ...--http-cors-allow-origin http://localhost:5173to narrow browser CORS to exact local origins
Health checks:
./target/debug/kheish-daemon status
./target/debug/kheish-daemon runtime getAgainst another daemon URL:
./target/debug/kheish-daemon --base-url http://127.0.0.1:4011 statusIf status or runtime get fails with a decode error such as a missing hooks field, the CLI and daemon are on different schema versions. Rebuild and restart the daemon, or talk to the matching binary.
Default Operating Workflow
1. Create a session
./target/debug/kheish-daemon sessions create demo2. Submit one input
Detached by default. Save the returned run_id.
./target/debug/kheish-daemon sessions input demo \
"Analyze the machine, inspect the relevant files, and summarize what you found."If you want provider/model overrides on one run:
./target/debug/kheish-daemon sessions input demo \
--provider openai \
--model gpt-5.4 \
"Analyze the machine and write a concise report."or:
./target/debug/kheish-daemon sessions input demo \
--provider anthropic \
--model claude-opus-4-6 \
"Analyze the machine and write a concise report."These overrides are run-scoped. They do not mutate the daemon globally.
3. Observe the run
./target/debug/kheish-daemon runs list --session-id demo
./target/debug/kheish-daemon runs get <run_id>
./target/debug/kheish-daemon runs wait <run_id>
./target/debug/kheish-daemon runs stream <run_id>4. Inspect the session
./target/debug/kheish-daemon sessions get demo
./target/debug/kheish-daemon sessions events demo
./target/debug/kheish-daemon sessions stream demoCompletion Semantics
Do not rely on implicit completion contracts inferred from the prompt. That behavior was removed.
Current rule:
- only explicit completion requirements are enforced
- otherwise verification is driven by prompt discipline, tools, tasks, and explicit reporting
Use explicit requirements only when you truly need a deterministic artifact contract:
./target/debug/kheish-daemon sessions input demo \
--require-workspace-file-path reports/demo.txt \
"Write the report into reports/demo.txt and then confirm the path."Do not use this for every file-producing task by reflex. Prefer normal agent verification unless the test specifically needs a hard artifact guarantee.
Approvals
Approvals are normal for shell-heavy or edit-heavy runs.
List approvals:
./target/debug/kheish-daemon approvals list
./target/debug/kheish-daemon approvals list --session-id demoApprove one:
./target/debug/kheish-daemon approvals allow demo approval-bash-1 --justification "approved"Approve the current wave:
./target/debug/kheish-daemon approvals allow-all \
--session-id demo \
--justification "approved for this run" \
--waitDeny:
./target/debug/kheish-daemon approvals deny-all \
--session-id demo \
--reason "unsafe"Rules:
- one
allow-allis not always enough - shell-heavy runs may produce multiple approval waves
- if
runs waitappears stuck, check approvals before assuming the run is hung runs getis the authority for run status
Provider and Model Routing
The daemon supports mixed-provider operation on the same process.
You can run:
- one session on
anthropic - another on
openai - or two runs in the same session with different explicit provider/model overrides
The resolved route is pinned per run. If you later change the daemon default model/provider, queued or active runs do not drift.
Sidechains also support explicit provider/model overrides:
./target/debug/kheish-daemon agents spawn-sidechain ... \
--provider openai \
--model gpt-5.4Shell Tasks
bash can run in foreground or background. Shell tasks are first-class daemon tasks.
Important commands:
./target/debug/kheish-daemon tasks list demo
./target/debug/kheish-daemon tasks get demo <task_id>
./target/debug/kheish-daemon tasks output demo <task_id>
./target/debug/kheish-daemon tasks output demo <task_id> --full
./target/debug/kheish-daemon tasks stop demo <task_id>Current behavior:
- background shell tasks persist output to disk
- foreground shell tasks are also represented as daemon tasks
- interrupted runs can leave a shell task alive and inspectable
task_outputandtask_stopare exposed to the default, coordinator, and verification agent profiles
Use this when validating long-running shell behavior:
- launch a long command
- inspect
tasks list - inspect
tasks output - stop the task and verify the terminal status
For the API and CLI shape, see docs/reference/tasks-schedules-agents-api.mdx.
Web Research
Current web research pattern is provider-neutral:
web_searchto discover sourcesweb_fetchonly when page-level details are needed
The system prompt now explicitly asks for:
- a
Sources:section - markdown links in the form
- [Title](URL)
This works on both Anthropic and OpenAI. Use real provider tests when touching:
web_search- prompt source guidance
- citations behavior
- web result parsing
MCP
kheish now has a real MCP path through kheish-mcp.
Operational notes:
- daemon startup can load MCP from Codex-compatible config and credentials files
- MCP tools are surfaced into runtime and prompt context
- runtime state includes MCP snapshot information
After startup, inspect runtime:
./target/debug/kheish-daemon runtime getLook for:
- active MCP tools
- MCP server instructions
When debugging MCP, validate on both providers. Good real scenarios:
- OpenAI docs MCP search + fetch
- Linear MCP list/query flow
Hooks
kheish now has real daemon-configurable hooks. This is no longer just test-only ToolHook plumbing.
Inspect hooks:
./target/debug/kheish-daemon runtime hooks getReplace hooks from a file:
./target/debug/kheish-daemon runtime hooks set --file hooks.jsonOr from stdin:
cat hooks.json | ./target/debug/kheish-daemon runtime hooks set --stdinUse hooks when validating:
- permission gating
- session start / end behavior
- worktree events
- task lifecycle interactions
Do not assume hook behavior from unit tests alone. Validate on a real daemon.
Debug Mode
Enable debug capture before the run you want to inspect:
./target/debug/kheish-daemon runtime set-debug-level fullLevels:
offonredactedfull
Important:
fullis daemon-global, not run-scoped- use it only on isolated daemon instances
- lower it again when done
Inspect a run bundle:
./target/debug/kheish-daemon runs debug <run_id>Inspect one artifact:
./target/debug/kheish-daemon runs debug-artifact <run_id> turn-0001-attempt-0001-model-request
./target/debug/kheish-daemon runs debug-artifact <run_id> turn-0001-attempt-0001-provider-request
./target/debug/kheish-daemon runs debug-artifact <run_id> turn-0001-attempt-0001-provider-events
./target/debug/kheish-daemon runs debug-artifact <run_id> turn-0001-attempt-0001-model-responseUse these first:
- system prompt actually sent
- tool surface actually sent
- provider request body
- provider event stream
- normalized final response
Multi-Agent Surface
Current control-plane commands:
./target/debug/kheish-daemon agents list
./target/debug/kheish-daemon agents get agent-1
./target/debug/kheish-daemon agents spawn-sidechain ...
./target/debug/kheish-daemon mailboxes post ...Agent-side tools now include:
spawn_agent- agent messaging/wait tools
- task tools
- plan/todo tools
- shell task follow-up tools
- web tools
Do not assume a specific profile has a tool. Check the actual surface or tests in crates/kheish-daemon/src/control_tools.rs.
Runtime Reconfiguration
You can change runtime settings without restarting the daemon:
./target/debug/kheish-daemon runtime set-model claude-opus-4-6
./target/debug/kheish-daemon runtime set-permission-mode accept-edits
./target/debug/kheish-daemon runtime set-debug-level redacted
./target/debug/kheish-daemon runtime set-system-prompt --mode append \
"When a tool can perform the next step directly, use it instead of narrating intent."Always verify afterwards:
./target/debug/kheish-daemon runtime getRecommended Test Matrix
Minimum local validation before claiming a change is safe:
cargo test -p kheish-types -p kheish-core -p kheish-runtime --lib
cargo test -p kheish-coding-tools --lib
cargo test -p kheish-daemon --libFor live provider validation:
set -a
source .env
set +a
cargo test -p kheish-daemon --test anthropic_hooks_live -- --nocapture
cargo test -p kheish-daemon --test openai_live -- --nocaptureWhen a change touches the daemon behavior, also validate with the real binary:
- start an isolated daemon
- hit it through the CLI
- use a fresh session
- verify the final artifact or final answer directly
Do this especially for:
- approvals
- shell tasks
- provider routing
- hooks
- MCP
- web research
- multi-agent behavior
Suggested Real E2E Scenarios
Report scenario
./target/debug/kheish-daemon sessions create report-demo
./target/debug/kheish-daemon sessions input report-demo \
--provider anthropic \
--model claude-opus-4-6 \
"Analyze the machine, inspect relevant system details, and write a report in reports/report-demo.txt"Non-file verification scenario
./target/debug/kheish-daemon sessions create inspect-demo
./target/debug/kheish-daemon sessions input inspect-demo \
--provider openai \
--model gpt-5.4 \
"Inspect the workspace root, summarize the current directory layout, and explicitly say what you verified."Web-sourced post scenario
./target/debug/kheish-daemon runtime set-permission-mode bypass-permissions
./target/debug/kheish-daemon sessions create web-post-demo
./target/debug/kheish-daemon sessions input web-post-demo \
--provider openai \
--model gpt-5.4 \
"Use web_search and web_fetch to write a sourced markdown post about stale-while-revalidate into posts/swr.md. Include a Sources: section with markdown links."Background shell scenario
Ask the agent to launch a long bash task in background, then inspect it with tasks list and tasks output.
Known Operational Pitfalls
- State-root mixups are common. Many apparent bugs are actually “wrong daemon / wrong state root”.
- CLI/daemon schema drift is real. If decode errors mention missing fields, rebuild and restart the daemon or use a matching CLI.
- Fresh sessions are better than resurrected sessions for product validation. Old interrupted sessions are useful for debugging, not for clean validation.
- Killed daemons can leave awkward recovery state around approvals or foreground shell tasks.
Inspect
runs get,approvals list,sessions get, andtasks listtogether before resuming. - Shell-heavy runs often need more than one approval wave.
web_searchquality depends on the actual HTML search response shape. If it suddenly returns empty results, inspect the provider output and the search HTML before blaming the prompt.- OpenAI live scenarios are more reliable with an explicit
--model gpt-5.4.
Evidence-First Debugging Order
When a run looks wrong, prefer this order:
runs get <run_id>approvals list --session-id <session_id>tasks list <session_id>tasks output <session_id> <task_id>sessions get <session_id>sessions events <session_id>runs debug <run_id>- state files only if the daemon is unavailable
Quick Reference
Daemon:
./target/debug/kheish-daemon serve --bind 127.0.0.1:4000 --state-root .kheish-daemon --workspace-root ./.kheish-workspace
./target/debug/kheish-daemon status
./target/debug/kheish-daemon doctorSessions:
./target/debug/kheish-daemon sessions create demo
./target/debug/kheish-daemon sessions get demo
./target/debug/kheish-daemon sessions input demo "..."
./target/debug/kheish-daemon sessions events demo
./target/debug/kheish-daemon sessions stream demo
./target/debug/kheish-daemon sessions interrupt demo
./target/debug/kheish-daemon sessions end demo --reason "done"Runs:
./target/debug/kheish-daemon runs list --session-id demo
./target/debug/kheish-daemon runs get <run_id>
./target/debug/kheish-daemon runs wait <run_id>
./target/debug/kheish-daemon runs stream <run_id>
./target/debug/kheish-daemon runs cancel <run_id>
./target/debug/kheish-daemon runs debug <run_id>
./target/debug/kheish-daemon runs debug-artifact <run_id> <artifact-id>Approvals:
./target/debug/kheish-daemon approvals list --session-id demo
./target/debug/kheish-daemon approvals allow-all --session-id demo --justification "approved"
./target/debug/kheish-daemon approvals deny-all --session-id demo --reason "unsafe"Tasks:
./target/debug/kheish-daemon tasks list demo
./target/debug/kheish-daemon tasks get demo <task_id>
./target/debug/kheish-daemon tasks output demo <task_id> --full
./target/debug/kheish-daemon tasks stop demo <task_id>Runtime:
./target/debug/kheish-daemon runtime get
./target/debug/kheish-daemon runtime hooks get
./target/debug/kheish-daemon runtime set-model claude-opus-4-6
./target/debug/kheish-daemon runtime set-permission-mode default
./target/debug/kheish-daemon runtime set-debug-level full
./target/debug/kheish-daemon runtime set-system-prompt --mode append "..."If you need architecture detail, start with:
README.md
If you need ground truth about behavior, trust:
- the daemon CLI
- real provider runs
- debug artifacts
- daemon tests
Use raw state files only as a fallback.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

