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
8 changes: 7 additions & 1 deletion src/agents/pi-embedded-runner/extra-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { streamSimple } from "@mariozechner/pi-ai";
import type { OpenClawConfig } from "../../config/config.js";
import { log } from "./logger.js";

// AIMLAPI defaults max_tokens to 512 when not set, which truncates tool call JSON.
// Override with a safe default so tool calls are never silently cut off.
const AIMLAPI_DEFAULT_MAX_TOKENS = 32768;

const OPENROUTER_APP_HEADERS: Record<string, string> = {
"HTTP-Referer": "https://openclaw.ai",
"X-Title": "OpenClaw",
Expand Down Expand Up @@ -337,7 +341,9 @@ export function applyExtraParamsToAgent(
Object.entries(extraParamsOverride).filter(([, value]) => value !== undefined),
)
: undefined;
const merged = Object.assign({}, extraParams, override);
const providerDefaults: Record<string, unknown> =
provider === "aimlapi" ? { maxTokens: AIMLAPI_DEFAULT_MAX_TOKENS } : {};
const merged = Object.assign({}, providerDefaults, extraParams, override);
const wrappedStreamFn = createStreamFnWithExtraParams(agent.streamFn, merged, provider);

if (wrappedStreamFn) {
Expand Down
2 changes: 1 addition & 1 deletion src/infra/openclaw-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";

const CORE_PACKAGE_NAMES = new Set(["openclaw"]);
const CORE_PACKAGE_NAMES = new Set(["openclaw", "openclaw-aimlapi"]);

async function readPackageName(dir: string): Promise<string | null> {
try {
Expand Down
Loading