惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
Martin Fowler
Martin Fowler
B
Blog RSS Feed
D
DataBreaches.Net
L
LangChain Blog
月光博客
月光博客
S
SegmentFault 最新的问题
阮一峰的网络日志
阮一峰的网络日志
V
Visual Studio Blog
美团技术团队
Jina AI
Jina AI
博客园 - 司徒正美
雷峰网
雷峰网
Last Week in AI
Last Week in AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
小众软件
小众软件
罗磊的独立博客
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: expose agent runtime status metadata · openclaw/open...
steipete · 2026-04-29 · via Recent Commits to openclaw:main

@@ -0,0 +1,145 @@

1+

import type { AgentRuntimePolicyConfig } from "../config/types.agents-shared.js";

2+

import type { OpenClawConfig } from "../config/types.openclaw.js";

3+

import { normalizeAgentId } from "../routing/session-key.js";

4+

import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";

5+

import { resolveAgentRuntimePolicy } from "./agent-runtime-policy.js";

6+

import { listAgentEntries } from "./agent-scope.js";

7+

import {

8+

normalizeEmbeddedAgentRuntime,

9+

resolveEmbeddedAgentHarnessFallback,

10+

type EmbeddedAgentHarnessFallback,

11+

type EmbeddedAgentRuntime,

12+

} from "./pi-embedded-runner/runtime.js";

13+14+

export type AgentRuntimeMetadata = {

15+

id: string;

16+

fallback?: "pi" | "none";

17+

source: "env" | "agent" | "defaults" | "implicit";

18+

};

19+20+

function normalizeRuntimeValue(value: unknown): EmbeddedAgentRuntime | undefined {

21+

const normalized = typeof value === "string" ? normalizeLowercaseStringOrEmpty(value) : "";

22+

return normalized ? normalizeEmbeddedAgentRuntime(normalized) : undefined;

23+

}

24+25+

function normalizeAgentHarnessFallback(

26+

value: EmbeddedAgentHarnessFallback | undefined,

27+

runtime: EmbeddedAgentRuntime,

28+

): EmbeddedAgentHarnessFallback {

29+

if (value) {

30+

return value === "none" ? "none" : "pi";

31+

}

32+

return runtime === "auto" ? "pi" : "none";

33+

}

34+35+

function isPluginAgentRuntime(runtime: string): boolean {

36+

return runtime !== "auto" && runtime !== "pi";

37+

}

38+39+

function resolveEffectiveFallback(params: {

40+

envFallback?: EmbeddedAgentHarnessFallback;

41+

envRuntime?: string;

42+

runtime: EmbeddedAgentRuntime;

43+

agentPolicy?: AgentRuntimePolicyConfig;

44+

defaultsPolicy?: AgentRuntimePolicyConfig;

45+

}): EmbeddedAgentHarnessFallback | undefined {

46+

if (params.envFallback) {

47+

return params.envFallback;

48+

}

49+50+

if (params.envRuntime && isPluginAgentRuntime(params.runtime)) {

51+

return normalizeAgentHarnessFallback(undefined, params.runtime);

52+

}

53+54+

if (params.agentPolicy?.id) {

55+

return normalizeAgentHarnessFallback(params.agentPolicy.fallback, params.runtime);

56+

}

57+58+

if (

59+

params.envRuntime ||

60+

params.defaultsPolicy?.id ||

61+

params.agentPolicy?.fallback ||

62+

params.defaultsPolicy?.fallback

63+

) {

64+

return normalizeAgentHarnessFallback(

65+

params.agentPolicy?.fallback ?? params.defaultsPolicy?.fallback,

66+

params.runtime,

67+

);

68+

}

69+70+

return undefined;

71+

}

72+73+

export function resolveAgentRuntimeMetadata(

74+

cfg: OpenClawConfig,

75+

agentId: string,

76+

env: NodeJS.ProcessEnv = process.env,

77+

): AgentRuntimeMetadata {

78+

const envFallback = resolveEmbeddedAgentHarnessFallback(env);

79+

const envRuntime = normalizeRuntimeValue(env.OPENCLAW_AGENT_RUNTIME);

80+

const normalizedAgentId = normalizeAgentId(agentId);

81+

const agentEntry = listAgentEntries(cfg).find(

82+

(entry) => normalizeAgentId(entry.id) === normalizedAgentId,

83+

);

84+

const agentPolicy = resolveAgentRuntimePolicy(agentEntry);

85+

const defaultsPolicy = resolveAgentRuntimePolicy(cfg.agents?.defaults);

86+87+

if (envRuntime) {

88+

return {

89+

id: envRuntime,

90+

fallback: resolveEffectiveFallback({

91+

envFallback,

92+

envRuntime,

93+

runtime: envRuntime,

94+

agentPolicy,

95+

defaultsPolicy,

96+

}),

97+

source: "env",

98+

};

99+

}

100+101+

const agentRuntime = normalizeRuntimeValue(agentPolicy?.id);

102+

if (agentRuntime) {

103+

return {

104+

id: agentRuntime,

105+

fallback: resolveEffectiveFallback({

106+

envFallback,

107+

runtime: agentRuntime,

108+

agentPolicy,

109+

defaultsPolicy,

110+

}),

111+

source: envFallback ? "env" : "agent",

112+

};

113+

}

114+115+

const defaultsRuntime = normalizeRuntimeValue(defaultsPolicy?.id);

116+

if (defaultsRuntime) {

117+

return {

118+

id: defaultsRuntime,

119+

fallback: resolveEffectiveFallback({

120+

envFallback,

121+

runtime: defaultsRuntime,

122+

agentPolicy,

123+

defaultsPolicy,

124+

}),

125+

source: envFallback ? "env" : agentPolicy?.fallback ? "agent" : "defaults",

126+

};

127+

}

128+129+

return {

130+

id: "pi",

131+

fallback: resolveEffectiveFallback({

132+

envFallback,

133+

runtime: "pi",

134+

agentPolicy,

135+

defaultsPolicy,

136+

}),

137+

source: envFallback

138+

? "env"

139+

: agentPolicy?.fallback

140+

? "agent"

141+

: defaultsPolicy?.fallback

142+

? "defaults"

143+

: "implicit",

144+

};

145+

}