mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:10:44 +00:00
fix: import claude cli history for anthropic sessions
This commit is contained in:
@@ -21,6 +21,7 @@ Docs: https://docs.openclaw.ai
|
||||
|
||||
### Fixes
|
||||
|
||||
- Gateway/chat history: merge Claude CLI transcript imports for Anthropic-routed sessions that still have a Claude CLI binding, so local chat history does not hide CLI JSONL turns. Fixes #75850. Thanks @alfredjbclaw.
|
||||
- Cron: make scheduler reload schedule comparison tolerate malformed persisted jobs, so one bad cron entry no longer aborts the whole tick. Fixes #75886. Thanks @samfox-ai.
|
||||
- Doctor/channels: warn after migrations when default Telegram or Discord accounts have no configured token and their env fallback (`TELEGRAM_BOT_TOKEN` or `DISCORD_BOT_TOKEN`) is unavailable, with secret-safe migration docs for checking state-dir `.env`. Fixes #74298. Thanks @lolaopenclaw.
|
||||
- Control UI/chat: keep live replies visible when a raw session alias such as `main` sends the chat turn but Gateway emits events under the canonical session key for the same run. Fixes #73716. Thanks @teebes.
|
||||
|
||||
@@ -256,6 +256,73 @@ describe("cli session history", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("augments anthropic-routed chat history when a Claude CLI binding has local messages", async () => {
|
||||
await withClaudeProjectsDir(async ({ homeDir, sessionId }) => {
|
||||
const messages = augmentChatHistoryWithCliSessionImports({
|
||||
entry: {
|
||||
sessionId: "openclaw-session",
|
||||
updatedAt: Date.now(),
|
||||
cliSessionBindings: {
|
||||
"claude-cli": {
|
||||
sessionId,
|
||||
},
|
||||
},
|
||||
},
|
||||
provider: "anthropic",
|
||||
localMessages: [
|
||||
{
|
||||
role: "assistant",
|
||||
content: "local assistant turn",
|
||||
timestamp: Date.parse("2026-03-26T16:29:57.000Z"),
|
||||
},
|
||||
],
|
||||
homeDir,
|
||||
});
|
||||
|
||||
expect(messages).toHaveLength(4);
|
||||
expect(messages).toContainEqual(
|
||||
expect.objectContaining({
|
||||
role: "assistant",
|
||||
content: "local assistant turn",
|
||||
}),
|
||||
);
|
||||
expect(messages).toContainEqual(
|
||||
expect.objectContaining({
|
||||
role: "user",
|
||||
__openclaw: expect.objectContaining({ cliSessionId: sessionId }),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("does not import stale Claude CLI history for unrelated providers with local messages", async () => {
|
||||
await withClaudeProjectsDir(async ({ homeDir, sessionId }) => {
|
||||
const localMessages = [
|
||||
{
|
||||
role: "assistant",
|
||||
content: "local OpenAI turn",
|
||||
timestamp: Date.parse("2026-03-26T16:29:57.000Z"),
|
||||
},
|
||||
];
|
||||
const messages = augmentChatHistoryWithCliSessionImports({
|
||||
entry: {
|
||||
sessionId: "openclaw-session",
|
||||
updatedAt: Date.now(),
|
||||
cliSessionBindings: {
|
||||
"claude-cli": {
|
||||
sessionId,
|
||||
},
|
||||
},
|
||||
},
|
||||
provider: "openai",
|
||||
localMessages,
|
||||
homeDir,
|
||||
});
|
||||
|
||||
expect(messages).toBe(localMessages);
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to legacy cliSessionIds when bindings are absent", async () => {
|
||||
await withClaudeProjectsDir(async ({ homeDir, sessionId }) => {
|
||||
const messages = augmentChatHistoryWithCliSessionImports({
|
||||
|
||||
@@ -10,6 +10,8 @@ import {
|
||||
} from "./cli-session-history.claude.js";
|
||||
import { mergeImportedChatHistoryMessages } from "./cli-session-history.merge.js";
|
||||
|
||||
const ANTHROPIC_PROVIDER = "anthropic";
|
||||
|
||||
export {
|
||||
mergeImportedChatHistoryMessages,
|
||||
readClaudeCliFallbackSeed,
|
||||
@@ -34,6 +36,7 @@ export function augmentChatHistoryWithCliSessionImports(params: {
|
||||
if (
|
||||
normalizedProvider &&
|
||||
normalizedProvider !== CLAUDE_CLI_PROVIDER &&
|
||||
normalizedProvider !== ANTHROPIC_PROVIDER &&
|
||||
params.localMessages.length > 0
|
||||
) {
|
||||
return params.localMessages;
|
||||
|
||||
Reference in New Issue
Block a user