Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ brief instead of spawning a native subagent. The worker starts with a clean
context, so nothing leaks between it and the main conversation, and only its
final report comes back. The main agent keeps design decisions and final review.

- **Default profile first:** new runs inherit `OFFLOAD_PROFILE` or the configured
default; explicit per-run overrides remain available when requested or required.
- **Two backends:** Codex CLI and Claude Code with Anthropic-compatible gateways.
- **Default profile first:** new runs inherit `OFFLOAD_PROFILE`, the default for an
explicit `--caller`, or the configured default; explicit per-run overrides remain
available when requested or required.
- **Two backends:** Codex CLI and Claude Code, through Anthropic-compatible gateways
or Claude Code's own official login (`"auth_mode": "native"`).
- **Named profiles:** a model, provider or managed Codex account, with an optional hint about which tasks it suits.
- **Persistent sessions:** resume related work and inspect previous reports.
- **macOS dashboard:** track tasks, switch profiles and manage accounts.
Expand Down Expand Up @@ -51,8 +53,9 @@ offload stats # usage and estimated costs
```

`-p` selects a profile for one task; `offload default <name>` changes the saved
default. `OFFLOAD_PROFILE` overrides that default. Resumes retain their recorded
account. Costs are estimates when available, not billing records.
default. `OFFLOAD_PROFILE` overrides that default. `offload default --caller <id>
<name>` sets a profile for runs that pass `--caller <id>`, a routing convenience and
not access control. Resumes retain their recorded profile and account. Costs are estimates when available, not billing records.

**Execution scope:** default-policy Codex workers bypass approvals and sandboxing.
`-w` communicates write intent; it does not enforce a filesystem boundary. Give
Expand Down
16 changes: 14 additions & 2 deletions docs/execution-pkg-detail.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
No exported signature requires importing an `internal` package. `New` validates
and snapshots the explicit profile without starting a native process.
`LoadConfig` reads the given absolute config file and resolves the named profile;
it never saves config or changes global defaults. Requests use an existing
it never saves config or changes global defaults, and it copies `AuthMode`.
`Profile.AuthMode` is empty (gateway) or `native`; it is omitted from
`ProfileFingerprint` when empty, so fingerprints of existing gateway and Codex
profiles are unchanged, while a native profile hashes differently from the same
profile in gateway mode. `ListProfiles` reports `AuthMode` `native` for it.
Per-caller default profiles are a CLI selection feature; the package still takes
an explicit profile name and never reads `caller_defaults`. Requests use an existing
absolute directory; native continuation is explicit, with no automatic lookup
or retry on a missing native session.

Expand Down Expand Up @@ -129,7 +135,13 @@ assembly. Caller instructions use a private temporary file, the task uses stdin,
and images use native stream-JSON blocks. Normal native project discovery remains
owned by Claude; extraction and restricted reads exclude ambient instructions.
Credentials always come from the selected Offload profile, never an ambient
native profile's settings or caller ANTHROPIC variables. The optional stream
native profile's settings or caller ANTHROPIC variables. A Claude profile with
`AuthMode: "native"` is the one exception: it sets no gateway variables, resolves
no token and makes no gateway reachability check, passes `--model`, omits
`--bare` (which never reads the official login) and still removes every caller
`ANTHROPIC_*` variable and passes `--setting-sources ""`. It requires a `Model`
and no `BaseURL`, `Token`, `TokenCmd` or `Endpoint`, applies to Claude only, and
cannot be combined with an isolated `EnvironmentDirectory`. The optional stream
environment accepts only the validated streaming-recovery switch and positive
output-token limit; it is applied consistently to child environment and settings.

Expand Down
4 changes: 3 additions & 1 deletion docs/execution-pkg.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ events, cancellation, timeout and process cleanup. Execution completion never
implies business acceptance or memory publication.

Configuration is explicit: construct a client with a resolved profile, or load a
named profile from an explicit absolute configuration path. A request supplies
named profile from an explicit absolute configuration path. A Claude profile with
`AuthMode: "native"` uses the installed Claude Code's official login and needs no
`BaseURL`, `Token` or `TokenCmd`; an empty `AuthMode` is the gateway mode. A request supplies
the task, working directory, internal instructions and optional native session.
The caller cancels through its context; the package installs no process-wide
signal handlers and does not change cwd or environment.
Expand Down
37 changes: 34 additions & 3 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ Run `offload config`, select **Profile**, then **Add profile** to save a bundle

Optional `endpoint` (`cc` for a Claude Code proxy, `llm` for a generic LLM gateway) applies to Claude profiles only. It is an informational label shown by `offload profiles` and in the settings wizard; it does not change requests. Unknown values and Codex profiles with an endpoint are rejected.

### Official Claude (native login)

A Claude profile with `"auth_mode": "native"` runs the installed Claude Code with its own official login (OAuth or keychain) instead of a gateway. Sign in once with the `claude` CLI. A native profile needs a `model` (an alias such as `sonnet`, or a full model name) and must not set `base_url`, `token`, `token_cmd` or `endpoint`; an empty or absent `auth_mode` keeps the gateway behavior above. Native auth applies to Claude profiles only.

```sh
offload profile save --json <<'JSON'
{"name":"claude-sonnet","create":true,"backend":"claude","model":"sonnet","auth_mode":"native"}
JSON
offload -p claude-sonnet -d /absolute/path/app "Summarize README.md, max 5 bullets."
```

For a native run, offload still drops every caller `ANTHROPIC_*` variable and keeps `--setting-sources ""`, so an ambient key, token or gateway URL cannot redirect the worker. It sets no `ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN` or `ANTHROPIC_MODEL`, runs no token command, makes no gateway reachability check, and passes the model as `--model` instead. It omits `--bare`, because `--bare` never reads OAuth or the keychain, and sets `CLAUDE_CODE_DISABLE_AUTO_MEMORY=1`. Permission and tool behavior match gateway runs. A native profile cannot be combined with an isolated execution environment, which replaces the home that holds the login. `offload profiles --json` reports `auth_mode: "native"` with an empty `base_url`. Switch an existing profile with `{"name":"…","auth_mode":"native"}` (this clears its gateway settings) or back with `auth_mode` `token` or `token_cmd` plus a `base_url` and `secret`.

### How switching works

Profiles select a `backend`: `claude` (the default for existing profiles) or `codex`. Claude profiles provide the three variables Claude Code reads. For each Claude run, offload drops every `ANTHROPIC_*` variable from the caller's environment and sets exactly:
Expand All @@ -77,10 +90,26 @@ Interrupted Codex runs retain progress and a resume command. Automatic tool-less

### Choosing a profile

Choose per run with `-p name`, per shell with `OFFLOAD_PROFILE=name`, otherwise through `default` in the config. `offload profiles` lists profiles (name, backend, endpoint or `-`, model, base URL), with `*` marking the selected default; it never prints tokens.
Choose per run with `-p name`, per shell with `OFFLOAD_PROFILE=name`, per calling tool with a [caller default](#per-caller-default-profiles), otherwise through `default` in the config. `offload profiles` lists profiles (name, backend, endpoint or `-`, model, base URL), with `*` marking the selected default; it never prints tokens.

Profiles may declare `"aliases": ["cc", "fast"]`. Each alias must match `[a-z0-9-]{1,32}`, be unique across all profiles, and differ from every profile name. Use aliases with `-p cc`, `OFFLOAD_PROFILE=cc`, or `offload default cc`; the saved default and run records use the resolved full name. JSON results and history also include `profile_alias` when an alias selected the run. Resuming a session keeps its stored profile name. `offload profiles` displays aliases, and `offload config` lets you edit a comma-separated alias list (clear it to remove all aliases).

### Per-caller default profiles

An external main agent can have its own default profile, so Claude Code and Codex each delegate through the profile that suits them. The key is the `--caller` ID that agent passes on every call:

```sh
offload default --caller claude claude-sonnet # saved as caller_defaults.claude
offload default --caller codex codex
offload default --caller claude # print it (the global default if none is set)
```

The profile may be an alias; the canonical name is saved. The caller follows the `--caller` rules (lowercase `[a-z0-9][a-z0-9._-]{0,63}`; `unspecified` is refused). There is no clearing syntax yet; point the caller at another profile, or edit `caller_defaults` in `config.json`.

New runs choose the profile in this order: `-p`; the profile a resumed session or named thread is bound to; `OFFLOAD_PROFILE`; the default mapped to an **explicitly supplied** `--caller`; the global default. A run without `--caller`, or with a caller that has no mapping, uses the global default; `unspecified` never matches. A mapped profile that is missing or disabled fails the run instead of falling back; one that is only marked unavailable is still selected, like `-p`. Resuming (`-r`, `-thread`, `offload resume`) keeps the session's original profile after any default changes. A profile that a caller default names cannot be disabled or deleted until that caller points elsewhere.

`--caller` is a routing convenience, not authentication or access control: any process can pass any caller ID. `offload profiles --json` adds a `caller_defaults` object (empty when none); `configured_default`, `active` and `active_source` stay global.

```bash
offload profiles
offload default codex # save Codex as the default
Expand Down Expand Up @@ -325,14 +354,16 @@ offload schedule add|list|show|update|pause|resume|delete|results|start|status
offload profiles [--json] list profiles (* = the one a run would use); --json is a redacted machine-readable list
offload profile save --json create or edit one profile from a JSON request on stdin
offload default [profile] show or set the saved default profile
offload default --caller ID [profile]
show or set the profile new runs with --caller ID use
offload mode [basic|proactive] show or set the saved delegation mode
offload install-agent [flags] install skills and delegation agent instructions
offload agent status [--json] user-scope skill/instruction state for Codex and Claude Code
offload agent enable|disable --agent codex|claude|all [--json]
offload feedback print the project homepage URL and open it in the default browser
offload version

-p profile profile name (default: $OFFLOAD_PROFILE, then config default)
-p profile profile name (default: $OFFLOAD_PROFILE, then the --caller default, then config default)
-m model override the profile's model
-effort level override the profile's reasoning effort for this run
-fast Codex only: priority (fast) tier for this run; -fast=false uses the default tier
Expand Down Expand Up @@ -729,7 +760,7 @@ See [execution-transcript.md](execution-transcript.md).

`-caller ID` (also `--caller ID`) optionally names the tool that invoked this run. It is
metadata only and is separate from `-caller-run-id`, which correlates one run with one
supervisor job. It changes no execution, authentication, profile or sandbox behavior.
supervisor job. It changes no execution, authentication or sandbox behavior. Its only effect on profile selection is the optional [per-caller default](#per-caller-default-profiles), and it is a routing convenience, not authentication or access control.

```sh
offload -json -caller agh -p codex -d /absolute/repo "Implement the assigned task"
Expand Down
3 changes: 2 additions & 1 deletion internal/agentinstall/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ const offloadAgentPolicy = offloadPolicyBegin + `

// subagentPolicy positions offload as the replacement for native subagents in both modes.
const subagentPolicy = `- Use offload in place of a native subagent for any clearly specified task that does not need your conversation: research, localization, review, implementation slices, checks. The worker starts with a clean context, so nothing from your conversation leaks in or out. Parallel work means several background offload runs. Independent review starts a fresh session on the active default; use a different profile/model only when explicitly requested or concretely required for independence, and state why. Keep a native subagent only when the task needs your forked conversation, needs host-only tools the worker lacks (browser, MCP or app tools), or is the Codex result waiter.
- For new runs, normally omit -p, -m, -effort and -fast so offload inherits an explicit OFFLOAD_PROFILE or the configured default and its settings. The use_for field is descriptive metadata and must not override a usable default. Never randomly choose or proactively rotate profiles/accounts, and never silently change provider, model, effort or tier. Override only for an explicit user request, a concrete task incompatibility, or a verified default failure with a user-authorized compatible fallback; explain the reason. If the default is unavailable or disabled, report the concrete failure instead of testing, enabling, editing or replacing it automatically. Do not invent profile names.`
- Pass --caller codex on every invocation when the supervising main agent is Codex, or --caller claude when it is Claude Code, including resumes. This selects that agent's configured caller default; it is routing metadata, not authentication or access control.
- For new runs, normally omit -p, -m, -effort and -fast so offload inherits an explicit OFFLOAD_PROFILE, then the --caller default, then the configured default and its settings. The use_for field is descriptive metadata and must not override a usable default. Never randomly choose or proactively rotate profiles/accounts, and never silently change provider, model, effort or tier. Override only for an explicit user request, a concrete task incompatibility, or a verified default failure with a user-authorized compatible fallback; explain the reason. If the selected default is unavailable or disabled, report the concrete failure instead of testing, enabling, editing or replacing it automatically. Do not invent profile names.`

// sessionReusePolicy is shared by both modes so the installed workflow stays identical.
const sessionReusePolicy = `- Reuse one worker session for related work: investigation, implementation, and review corrections of the same task or slice should use offload -r <session> without selection overrides (it keeps the original profile/account and directory). Each follow-up still states the current corrections and acceptance criteria, because backend compaction means history is not unlimited or verbatim. Start a new session for unrelated tasks, a different explicitly requested/required profile, or stale context; do not reuse one session for every task. Never send overlapping runs to one session. Inspect an interrupted run (offload show <session>, git diff) before continuing, and keep its partial edits. If the session's profile no longer exists, restore it or start a user-authorized new session with -p; offload never switches providers silently.
Expand Down
Loading
Loading