mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-28 15:01:41 +03:00
feat(agent): auto-enable GLM-4.7 thinking mode
Add automatic thinking mode support for Z.AI GLM-4.x models:
- GLM-4.7: Preserved thinking (clear_thinking: false)
- GLM-4.5/4.6: Interleaved thinking (clear_thinking: true)
Uses Z.AI Cloud API format: thinking: { type: "enabled", clear_thinking: boolean }
Includes patches for pi-ai, pi-agent-core, and pi-coding-agent to pass
extraParams through the stream pipeline. User can override via config
or disable via --thinking off.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Peter Steinberger
parent
3f93781b4b
commit
f7b32195cb
@@ -0,0 +1,46 @@
|
||||
diff --git a/dist/agent.js b/dist/agent.js
|
||||
index 0000000..1111111 100644
|
||||
--- a/dist/agent.js
|
||||
+++ b/dist/agent.js
|
||||
@@ -42,6 +42,8 @@ export class Agent {
|
||||
this.followUpMode = opts.followUpMode || "one-at-a-time";
|
||||
this.streamFn = opts.streamFn || streamSimple;
|
||||
this.getApiKey = opts.getApiKey;
|
||||
+ // PATCH: Support extraParams for provider-specific features (e.g., GLM-4.7 thinking mode)
|
||||
+ this.extraParams = opts.extraParams;
|
||||
}
|
||||
get state() {
|
||||
return this._state;
|
||||
@@ -193,6 +195,8 @@ export class Agent {
|
||||
convertToLlm: this.convertToLlm,
|
||||
transformContext: this.transformContext,
|
||||
getApiKey: this.getApiKey,
|
||||
+ // PATCH: Pass extraParams through to stream function
|
||||
+ extraParams: this.extraParams,
|
||||
getSteeringMessages: async () => {
|
||||
if (this.steeringMode === "one-at-a-time") {
|
||||
if (this.steeringQueue.length > 0) {
|
||||
diff --git a/dist/agent.d.ts b/dist/agent.d.ts
|
||||
index 0000000..1111111 100644
|
||||
--- a/dist/agent.d.ts
|
||||
+++ b/dist/agent.d.ts
|
||||
@@ -33,6 +33,10 @@ export interface AgentOptions {
|
||||
* Useful for expiring tokens (e.g., GitHub Copilot OAuth).
|
||||
*/
|
||||
getApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;
|
||||
+ /**
|
||||
+ * Extra params to pass to the provider API (e.g., Z.AI GLM thinking mode params).
|
||||
+ */
|
||||
+ extraParams?: Record<string, unknown>;
|
||||
}
|
||||
export declare class Agent {
|
||||
private _state;
|
||||
@@ -45,6 +49,8 @@ export declare class Agent {
|
||||
private followUpMode;
|
||||
streamFn: StreamFn;
|
||||
getApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;
|
||||
+ /** Extra params to pass to the provider API. */
|
||||
+ extraParams?: Record<string, unknown>;
|
||||
private runningPrompt?;
|
||||
private resolveRunningPrompt?;
|
||||
constructor(opts?: AgentOptions);
|
||||
Reference in New Issue
Block a user