fix: /resume latest searches all workspaces#2811
Conversation
|
hello @TheArchitectit , Can you also fix when xai configured and ask who are you the model respond that it is claude model yet it config it show xai is the one configured , and I dont have claude key so its xai model claim being claude , I recently sent this, here the old massage (Can you also fix this? ## xAI / Grok-3 Integration claw always routed requests to api.anthropic.com regardless of which model was specified. Using --model grok-3 still sent requests to Anthropic, causing 401 errors. AnthropicRuntimeClient.client was hardcoded to AnthropicClient, which always uses Authorization: x-api-key and sends to Anthropic's endpoint. ProviderClient already existed in the codebase and could route by model name prefix (grok-* → xAI, claude-* → Anthropic) but was never wired into the CLI runner. Fix: claw Says "I'm Claude Opus 4.6" When Using Grok When asked "what model are you?", claw replied "I'm Claude, specifically Claude 3.7 Sonnet" even when running grok-3. runtime/src/prompt.rs:38: pub const FRONTIER_MODEL_NAME: &str = "Claude Opus 4.6"; This was injected into every session's system prompt as: Model family: Claude Opus 4.6 Grok reads its own system prompt and reports that as its identity. No Anthropic API key required — it's just hardcoded text. Fix — claw-code-parity/rust/crates/runtime/src/lib.rs Fix — claw-code-parity/rust/crates/rusty-claude-cli/src/main.rs ) |
|
The other feature which allows you set to provider should take care of this? |
7b35024 to
51590cd
Compare
|
what else do you need to merge this in? |
Previously /resume latest only searched the current workspace's fingerprinted session directory. If you started claw from a different directory, it found zero sessions even though sessions existed elsewhere on disk. Changes: - Add global_sessions_root() pointing to ~/.claw/sessions/ - Add scan_global_sessions() to scan all workspace namespaces - Modify latest_session() to fall back to global scan when no workspace-local sessions are found - Add load_session_loose() that skips workspace validation for alias references (latest/last/recent) so cross-workspace resume works while still enforcing workspace check for explicit IDs - Wire load_session_loose() into CLI's load_session_reference() - Add provider field to config validation schema (needed because user's settings.json already has the provider key) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The previous implementation only scanned ~/.claw/sessions/ for the global fallback, but sessions are actually stored in the project-local <cwd>/.claw/sessions/<fingerprint>/ by SessionStore::from_cwd(). Now scans both the global root and the project-local parent directory (checking all fingerprint subdirs) so /resume latest finds sessions regardless of where they're stored. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Some OpenAI-compatible providers (e.g., GLM-5) omit the `id` field in streaming and non-streaming responses. Adding #[serde(default)] allows the parser to accept these responses instead of failing with "missing field `id`". Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds scripts/install.sh that builds the release binary and links it to ~/.local/bin/claw. Run after code changes to update the CLI. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
When a provider returns HTML (e.g., error page, wrong endpoint) instead of JSON in an SSE stream, provide a clear error message instead of hanging or failing with a cryptic parse error. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
When a provider returns a JSON error (e.g., {"error":{"message":"..."}})
without SSE framing (no "data:" prefix), the SSE parser was silently
ignoring it and hanging. Now detects and surfaces these errors.
Also handles HTML responses that lack SSE framing.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Some providers (GLM, DeepSeek) emit reasoning tokens in `reasoning_content` or nested `thinking.content` fields instead of `content`. Added support for these fields so reasoning models work correctly. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The final streaming chunk from some providers contains only finish_reason and usage, with no delta field. Made it optional to prevent parse errors. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
When preserve_recent_messages == 0, raw_keep_from equals messages.len(), causing index out of bounds when accessing session.messages[k]. Added k >= session.messages.len() check to prevent panic. Reason: Compaction with preserve_recent_messages=0 triggered OOB access when checking for tool-use/tool-result pair preservation at boundary. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
a3d1a90 to
79a41e1
Compare
Summary
Fixes
/resume latestnot finding sessions. Two separate bugs that together made session resume nearly unusable when switching directories.Problem this solves
Bug 1:
/resume latestonly searches current workspaceBefore: sessions were only searched in the current workspace's fingerprinted directory (
<cwd>/.claw/sessions/<fingerprint>/). If you startedclawfrom a different directory than where your session was created,/resume latestfound zero sessions even though sessions existed elsewhere on disk. Since sessions are partitioned by workspace fingerprint (hash of the CWD), switching directories made all previous sessions invisible.This is especially painful for users who work in multiple project directories — switching from
~/project-ato~/project-bmeans/resume latestin project-b can never find sessions from project-a.Fix: Three-tier session lookup fallback in
latest_session():<cwd>/.claw/sessions/~/.claw/sessions/scan_global_sessions()iterates all fingerprint subdirectories usingcollect_sessions_from_dir_unvalidated()which skips workspace validation. Results are sorted by recency.Bug 2:
/resume latestreturns the empty current sessionBefore:
/resume latestalways returned the most recently created session — which was the empty session just created on startup. So every time you ran/resume latestfrom a freshclawinstance, it would "resume" a brand new empty session instead of your previous conversation with actual history.Fix:
load_session_loose()skips:/resume latestfrom a running REPL doesn't return itself)message_count == 0(so empty startup sessions are skipped, returning the previous one with actual history)The exclude ID flows from the REPL CLI through
load_session_reference()→SessionStore::load_session_loose()→resolve_reference()→latest_session().Cross-workspace resume
load_session_loose()allows cross-workspace resume for alias references (latest,last,recent), printing a note like:Explicit session IDs still enforce workspace validation — you must be explicit about cross-workspace resume.
Files changed
runtime/src/session_control.rsglobal_sessions_root(),scan_global_sessions()with 3-tier fallback,load_session_loose()for cross-workspace aliases,collect_sessions_from_dir_unvalidated(). Updatedlatest_session()to try global fallback. Updated error message hint.runtime/src/config_validate.rsprovidertop-level field +PROVIDER_FIELDSconstant (shared with #2810 — needed because user's settings.json already contains the provider key)rusty-claude-cli/src/main.rsload_session_loose()for alias references so/resume latestcan find sessions across workspacescommands/src/lib.rs#[allow(clippy::unnecessary_wraps)]on two helper functions that returnResultfor future-proofingTest plan
cargo test --workspace— all tests passcargo clippy --workspace --all-targets -- -D warnings— clean/resume latestin REPL — returns previous session with messages, not empty current sessionclaw, have a conversation, exit, startclawagain,/resume latest— brings back the previous chat/resume <explicit-id>from different workspace — still errors with WorkspaceMismatch/resume latestfrom a completely different directory — finds session across workspaces💘 Generated with Crush