Skip to content

Commit aa286c2

Browse files
authored
Anthropic/XAI Optimizations (#866)
* anthropic cache management, extend default poll window, xai parallel * anth cache fix * harden * version bump * status view improvements * xai auth support, codex refactor, session tui fixes * improve wording/symbols * fix auth and session test isolation * otel warns --------- Co-authored-by: evalstate <evalstate@users.noreply.github.com>
1 parent 5ab8f42 commit aa286c2

90 files changed

Lines changed: 3281 additions & 824 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/docs/_generated/tui_runtime_reference.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@
3333
| `shell_execution.interactive_use_pty` | `SHELL_EXECUTION__INTERACTIVE_USE_PTY` | `bool` | `True` | Use a PTY for interactive prompt shell commands. |
3434
| `shell_execution.timeout_seconds` | `SHELL_EXECUTION__TIMEOUT_SECONDS` | `int` | `90` | Maximum seconds without command output before termination. |
3535
| `shell_execution.warning_interval_seconds` | `SHELL_EXECUTION__WARNING_INTERVAL_SECONDS` | `int` | `30` | Show timeout warnings every N seconds. |
36+
| `shell_execution.process_poll_max_wait_seconds` | `SHELL_EXECUTION__PROCESS_POLL_MAX_WAIT_SECONDS` | `int` | `250` | Maximum wait accepted by poll_process. |
37+
| `shell_execution.managed_process_poll_history_folding` | `SHELL_EXECUTION__MANAGED_PROCESS_POLL_HISTORY_FOLDING` | `Literal['auto', 'on', 'off']` | `auto` | Fold repetitive quiet poll_process exchanges. |
3638
| `tui.completion_menu_reserved_lines` | `TUI__COMPLETION_MENU_RESERVED_LINES` | `int` | `6` | Prompt-toolkit lines reserved below the input for completion menus. |

docs/docs/agents/instructions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The following variables are available in System Prompt templates:
2828
| <nobr>`{{agentType}}`</nobr> | Current agent type | |
2929
| <nobr>`{{agentCardPath}}`</nobr> | Source AgentCard path | `(internal)` when not loaded from a card |
3030
| <nobr>`{{agentCardDir}}`</nobr> | Directory containing the source AgentCard | `(internal)` when not loaded from a card |
31+
| <nobr>`{{modelReferences}}`</nobr> | Model references | Includes the effective `$system.default` Useful for instructing CLI based subagents |
3132
| <nobr>`{{model_specific}}`</nobr> | Model-specific prompt guidance from the resolved model catalog entry or model overlay | Empty when the selected model has no model-specific guidance |
3233
| <nobr>`{{hostPlatform}}`</nobr> | Host platform information | |
3334
| <nobr>`{{pythonVer}}`</nobr> | Python version | |
@@ -38,7 +39,7 @@ The following variables are available in System Prompt templates:
3839
```
3940
Environment:
4041
- Workspace root: /home/user/project
41-
- Client: Zed 0.232
42+
- Client: fast-agent (pid 12345)
4243
- Host platform: Linux-6.6.87.2-microsoft-standard-WSL2
4344
```
4445

docs/docs/guides/codex.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ connect to MCP Servers.
4646
If you want to use the Codex OAuth models directly, authenticate once first:
4747

4848
```bash
49-
fast-agent auth codexplan
49+
fast-agent auth login codex
5050
```
5151

5252
This stores the token in your OS keyring. After that you can use Codex OAuth

docs/docs/mcp/mcp-oauth.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,22 @@ Notes:
6565

6666
- Show auth status (keyring backend, stored identities, configured servers → identities)
6767
- `fast-agent auth`
68-
- `fast-agent auth status`
68+
- `fast-agent auth mcp status`
6969
- Single target:
70-
- `fast-agent auth status https://example-server.modelcontextprotocol.io`
71-
- `fast-agent auth status myserver`
70+
- `fast-agent auth mcp status https://example-server.modelcontextprotocol.io`
71+
- `fast-agent auth mcp status myserver`
7272

7373
- Proactive login (perform OAuth and store tokens)
7474
- By server name in config:
75-
- `fast-agent auth login myserver`
75+
- `fast-agent auth mcp login myserver`
7676
- By identity (ad hoc, no config):
77-
- HTTP (default): `fast-agent auth login https://example-server.modelcontextprotocol.io`
78-
- SSE: `fast-agent auth login https://example-server.modelcontextprotocol.io --transport sse`
77+
- HTTP (default): `fast-agent auth mcp login https://example-server.modelcontextprotocol.io`
78+
- SSE: `fast-agent auth mcp login https://example-server.modelcontextprotocol.io --transport sse`
7979

8080
- Clear tokens
81-
- By identity (base URL): `fast-agent auth clear --identity https://example-server.modelcontextprotocol.io`
82-
- By server name (from config): `fast-agent auth clear myserver`
83-
- All identities: `fast-agent auth clear --all`
81+
- By identity (base URL): `fast-agent auth mcp logout --identity https://example-server.modelcontextprotocol.io`
82+
- By server name (from config): `fast-agent auth mcp logout myserver`
83+
- All identities: `fast-agent auth mcp logout --all`
8484

8585
- Check full app config (includes server OAuth flags and token presence):
8686
- `fast-agent check`
@@ -98,12 +98,12 @@ to an empty value to disable the built-in default.
9898
- A local callback server (`http://localhost:3030/callback`) captures the code; if the port is blocked, you’ll be prompted to paste the callback URL.
9999

100100
- Proactive login (no agent session needed)
101-
- `fast-agent auth login https://example-server.modelcontextprotocol.io`
101+
- `fast-agent auth mcp login https://example-server.modelcontextprotocol.io`
102102
- Complete the link flow once; tokens will be reused next time.
103103

104104
- Inspect and clear a specific identity
105-
- `fast-agent auth status https://example-server.modelcontextprotocol.io`
106-
- `fast-agent auth clear --identity https://example-server.modelcontextprotocol.io`
105+
- `fast-agent auth mcp status https://example-server.modelcontextprotocol.io`
106+
- `fast-agent auth mcp logout --identity https://example-server.modelcontextprotocol.io`
107107

108108
## Troubleshooting
109109

docs/docs/models/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ social:
99

1010
**`fast-agent`** has native support for **OpenAI Responses** and **Chat Completions**, **Anthropic Messages**, **Google GenAI** and **Amazon Bedrock** APIs.
1111

12-
OpenAI Codex users can use their subscription with **`fast-agent`**, using their existing installation or logging in with `fast-agent auth codexplan`.
12+
OpenAI Codex users can use their subscription with **`fast-agent`**, using their existing installation or logging in with `fast-agent auth login codex`.
1313

1414
Chat Completions models are also available via **Microsoft Azure**, and supported Anthropic models are available on **Google Vertex**.
1515

docs/docs/models/llm_providers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The `default_headers` option is available for OpenAI-compatible providers (inclu
3434
| --- | --- | --- | --- |
3535
| OpenAI Responses | `responses` | `OPENAI_API_KEY` | Native Responses API, reasoning, web search, connectors, remote MCP |
3636
| OpenAI Chat Completions | `openai` | `OPENAI_API_KEY` | OpenAI-compatible Chat Completions models |
37-
| Codex Responses | `codexresponses` | `fast-agent auth codexplan` or `CODEX_API_KEY` | Codex subscription-backed Responses models; no provider-managed MCP/connectors |
37+
| Codex Responses | `codexresponses` | `fast-agent auth login codex` or `CODEX_API_KEY` | Codex subscription-backed Responses models; no provider-managed MCP/connectors |
3838
| Anthropic | `anthropic` | `ANTHROPIC_API_KEY` or Anthropic SDK credentials | Claude Messages API, prompt caching, web tools |
3939
| Google | `google` | `GOOGLE_API_KEY` | Native Gemini API |
4040
| Azure OpenAI | `azure` | `AZURE_OPENAI_API_KEY` | Azure deployments and optional DefaultAzureCredential |

docs/docs/models/model_overlays.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ metadata:
127127
- image/jpeg
128128
- image/png
129129
default_temperature: 0.8
130+
managed_process_poll_folding: true
130131
process_poll_default_wait_seconds: 30
131132
fast: true
132133

@@ -183,6 +184,10 @@ Common fields:
183184
- `context_window`
184185
- `max_output_tokens`
185186
- `tokenizes`
187+
- `managed_process_poll_folding`: whether automatic folding of repetitive
188+
quiet `poll_process` exchanges has been validated for this model. This is
189+
consulted when `shell_execution.managed_process_poll_history_folding` is
190+
`auto`.
186191
- `process_poll_default_wait_seconds`: default `poll_process` wait when the model
187192
omits `wait_sec` (`0` keeps polling non-blocking). The value is capped by
188193
`shell_execution.process_poll_max_wait_seconds`.

docs/docs/models/providers/openai.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Encrypted reasoning blocks are used to maintain model intelligence between tool
2828

2929
| Feature | `responses` | `codexresponses` | `openai` Chat Completions |
3030
| --- | --- | --- | --- |
31-
| Auth | `OPENAI_API_KEY` | `fast-agent auth codexplan` or `CODEX_API_KEY` | `OPENAI_API_KEY` |
31+
| Auth | `OPENAI_API_KEY` | `fast-agent auth login codex` or `CODEX_API_KEY` | `OPENAI_API_KEY` |
3232
| API surface | OpenAI Responses API | Codex Responses backend | Chat Completions API |
3333
| Curated aliases | `gpt55`, `gpt54`, `gpt52`, `codex`, `chatgpt` | `codexplan`, `codexplan54`, `codexspark` | `openai.gpt-4.1`, `openai.gpt-4o` |
3434
| Structured outputs | Yes, JSON schema where model supports it | Yes, JSON schema where model supports it | Yes, model-dependent Chat Completions structured outputs |
@@ -77,7 +77,7 @@ Examples:
7777
### Codex Responses models
7878

7979
Use `codexresponses` for Codex subscription-backed models. Authenticate with
80-
`fast-agent auth codexplan` or provide `CODEX_API_KEY`.
80+
`fast-agent auth login codex` or provide `CODEX_API_KEY`.
8181

8282
The `codexresponses` provider is similar to `responses`, with these main differences:
8383

@@ -208,7 +208,7 @@ for card-scoped runtime targets.
208208

209209
## Codex (OAuth Responses)
210210

211-
**`fast-agent`** supports using your OpenAI Codex subscription. Run `fast-agent auth codexplan`
211+
**`fast-agent`** supports using your OpenAI Codex subscription. Run `fast-agent auth login codex`
212212
once, then use a Codex OAuth model alias such as `codexplan` (GPT-5.5 planning),
213213
`codexplan54` (GPT-5.4 planning), `codexplan53` (GPT-5.3 Codex planning), or
214214
`codexspark` (GPT-5.3 Codex Spark).
@@ -217,7 +217,7 @@ once, then use a Codex OAuth model alias such as `codexplan` (GPT-5.5 planning),
217217

218218
```bash
219219
# Start OAuth login (stores tokens in your OS keyring)
220-
fast-agent auth codexplan
220+
fast-agent auth login codex
221221
222222
# Use the Codex planning model
223223
fast-agent --model codexplan
@@ -245,7 +245,7 @@ codexresponses:
245245

246246
**Notes:**
247247

248-
- Tokens are stored in your OS keyring via `fast-agent auth codexplan`.
248+
- Tokens are stored in your OS keyring, with a secure file fallback, via `fast-agent auth login codex`.
249249
- `codexplan` maps to `codexresponses.gpt-5.5?reasoning=medium`.
250250
- `codexplan54` maps to `codexresponses.gpt-5.4?reasoning=high`.
251251
- `codexplan53` maps to `codexresponses.gpt-5.3-codex?reasoning=medium`.
@@ -254,5 +254,6 @@ codexresponses:
254254
- Provider-managed MCP is **not** supported with `codexresponses`, including
255255
Codex OAuth aliases such as `codexplan`, `codexplan54`, and `codexspark`.
256256
Use `responses` instead when you need `management: provider`.
257-
- To remove tokens, use: `fast-agent auth codex-clear`.
257+
- To remove fast-agent-owned tokens, use: `fast-agent auth logout codex`. Codex
258+
CLI auth files are treated as read-only and are never modified or deleted.
258259
- `fast-agent check` and `fast-agent auth` show Codex OAuth status.

docs/docs/models/providers/xai.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,33 @@ social:
1111

1212
Use the `xai` provider for xAI Grok models. xAI supports both `web_search` and `x_search`; fast-agent sends `x_search` as xAI's provider-managed X Search tool.
1313

14+
## Sign in with a Grok/X subscription
15+
16+
```bash
17+
fast-agent auth login xai
18+
```
19+
20+
The device login opens an xAI verification URL and displays a code. Provider
21+
credentials use the OS keyring when it is writable and otherwise fall back to
22+
`~/.fast-agent/auth.json`. Access tokens refresh automatically before expiry.
23+
24+
The model selector also offers this login when an xAI model is selected without
25+
a configured credential.
26+
27+
Useful credential commands:
28+
29+
```bash
30+
fast-agent auth status xai
31+
fast-agent auth token xai
32+
fast-agent auth export xai ./xai.auth.json
33+
fast-agent auth logout xai
34+
```
35+
36+
An exported file contains only the selected provider and includes its refresh
37+
token. Set `FAST_AGENT_AUTH_FILE` to use that portable file. This is the
38+
recommended form for long-running Harbor jobs because refreshed credentials are
39+
written back to the staged file.
40+
1441
## Configure
1542

1643
```yaml
@@ -23,6 +50,9 @@ Environment variables:
2350

2451
- `XAI_API_KEY`: Your xAI API key
2552
- `XAI_BASE_URL`: Override the API endpoint
53+
- `FAST_AGENT_AUTH_FILE`: Explicit portable provider credential file
54+
55+
An explicit `xai.api_key` or `XAI_API_KEY` takes precedence over stored OAuth.
2656

2757
## Use a model
2858

docs/docs/ref/cmd_switches.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,18 @@ fast-agent export latest --hf-url hf://buckets/your-name/fast-agent-traces/
134134

135135
See the full reference [here](export_command/).
136136

137+
## fast-agent session Command
138+
139+
Remove empty session placeholders left by interrupted startups:
140+
141+
```bash
142+
fast-agent session prune --empty
143+
```
144+
145+
This preserves sessions with history, titles, previews, or pins. Run it when no
146+
other fast-agent process is starting or waiting for its first turn, because
147+
those live sessions are also empty until they persist content.
148+
137149
## fast-agent check Command
138150

139151
Use `fast-agent check` to diagnose your configuration:

0 commit comments

Comments
 (0)