From 884c1177852e72cc9e9d8382db0e8c2f3c6459d3 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 23 Apr 2026 17:31:32 +0100 Subject: [PATCH] ci: harden docs agent fetch retries --- .github/workflows/docs-agent.yml | 27 ++++++++++------ src/agents/tools/session-status-tool.ts | 2 +- src/auto-reply/reply/commands-status.ts | 3 +- src/status/status-text.ts | 41 +++---------------------- src/status/status-text.types.ts | 38 +++++++++++++++++++++++ 5 files changed, 62 insertions(+), 49 deletions(-) create mode 100644 src/status/status-text.types.ts diff --git a/.github/workflows/docs-agent.yml b/.github/workflows/docs-agent.yml index e1d2e0f7397..02afcc03aeb 100644 --- a/.github/workflows/docs-agent.yml +++ b/.github/workflows/docs-agent.yml @@ -55,7 +55,17 @@ jobs: exit 0 fi - git fetch --no-tags origin main + for attempt in 1 2 3 4 5; do + if git fetch --no-tags origin main; then + break + fi + if [ "$attempt" = "5" ]; then + echo "Failed to fetch main after retries." >&2 + exit 1 + fi + echo "Fetch attempt ${attempt} failed; retrying." + sleep $((attempt * 2)) + done remote_main="$(git rev-parse origin/main)" if [ "$remote_main" != "$WORKFLOW_HEAD_SHA" ]; then echo "CI run is superseded by ${remote_main}; skipping docs agent for ${WORKFLOW_HEAD_SHA}." @@ -156,29 +166,26 @@ jobs: exit 0 fi - git fetch --no-tags origin "${TARGET_BRANCH}" - remote_main="$(git rev-parse "origin/${TARGET_BRANCH}")" - if [ "$remote_main" != "$BASE_SHA" ]; then - echo "main advanced from ${BASE_SHA} to ${remote_main}; skipping stale docs update." - exit 0 - fi - git config user.name "openclaw-docs-agent[bot]" git config user.email "openclaw-docs-agent[bot]@users.noreply.github.com" git add docs README.md CHANGELOG.md git commit --no-verify -m "docs: refresh documentation" for attempt in 1 2 3 4 5; do + if ! git fetch --no-tags origin "${TARGET_BRANCH}"; then + echo "Fetch attempt ${attempt} failed; retrying." + sleep $((attempt * 2)) + continue + fi if git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:"${TARGET_BRANCH}"; then exit 0 fi - git fetch --no-tags origin "${TARGET_BRANCH}" remote_main="$(git rev-parse "origin/${TARGET_BRANCH}")" if [ "$remote_main" != "$BASE_SHA" ]; then echo "main advanced from ${BASE_SHA} to ${remote_main}; skipping stale docs update." exit 0 fi - echo "Push attempt ${attempt} failed; retrying." + echo "Docs update attempt ${attempt} failed; retrying." sleep $((attempt * 2)) done diff --git a/src/agents/tools/session-status-tool.ts b/src/agents/tools/session-status-tool.ts index acac48191d0..a76ca41dbb9 100644 --- a/src/agents/tools/session-status-tool.ts +++ b/src/agents/tools/session-status-tool.ts @@ -22,7 +22,7 @@ import { } from "../../routing/session-key.js"; import { applyModelOverrideToSessionEntry } from "../../sessions/model-overrides.js"; import { normalizeOptionalLowercaseString } from "../../shared/string-coerce.js"; -import type { BuildStatusTextParams } from "../../status/status-text.js"; +import type { BuildStatusTextParams } from "../../status/status-text.types.js"; import { buildTaskStatusSnapshotForRelatedSessionKeyForOwner } from "../../tasks/task-owner-access.js"; import { formatTaskStatusDetail, formatTaskStatusTitle } from "../../tasks/task-status.js"; import { loadModelCatalog } from "../model-catalog.js"; diff --git a/src/auto-reply/reply/commands-status.ts b/src/auto-reply/reply/commands-status.ts index 289dc97c585..c791ffb3aed 100644 --- a/src/auto-reply/reply/commands-status.ts +++ b/src/auto-reply/reply/commands-status.ts @@ -1,5 +1,6 @@ import { logVerbose } from "../../globals.js"; -import { buildStatusText, type BuildStatusTextParams } from "../../status/status-text.js"; +import { buildStatusText } from "../../status/status-text.js"; +import type { BuildStatusTextParams } from "../../status/status-text.types.js"; import type { ReplyPayload } from "../types.js"; import type { CommandContext } from "./commands-types.js"; export { buildStatusText } from "../../status/status-text.js"; diff --git a/src/status/status-text.ts b/src/status/status-text.ts index 9659453c9f9..1c385a97d7b 100644 --- a/src/status/status-text.ts +++ b/src/status/status-text.ts @@ -14,21 +14,15 @@ import { } from "../agents/tools/sessions-helpers.js"; import { normalizeGroupActivation } from "../auto-reply/group-activation.js"; import { resolveSelectedAndActiveModel } from "../auto-reply/model-runtime.js"; -import type { - ElevatedLevel, - ReasoningLevel, - ThinkLevel, - VerboseLevel, -} from "../auto-reply/thinking.js"; +import type { ThinkLevel } from "../auto-reply/thinking.js"; import { toAgentModelListLike } from "../config/model-input.js"; -import type { SessionEntry, SessionScope } from "../config/sessions.js"; +import type { SessionEntry } from "../config/sessions.js"; import type { OpenClawConfig } from "../config/types.openclaw.js"; import { formatUsageWindowSummary, loadProviderUsageSummary, resolveUsageProviderId, } from "../infra/provider-usage.js"; -import type { MediaUnderstandingDecision } from "../media-understanding/types.js"; import { normalizeOptionalLowercaseString } from "../shared/string-coerce.js"; import { listTasksForAgentIdForStatus, @@ -39,35 +33,8 @@ import { formatTaskStatusDetail, formatTaskStatusTitle, } from "../tasks/task-status.js"; - -export type BuildStatusTextParams = { - cfg: OpenClawConfig; - sessionEntry?: SessionEntry; - sessionKey: string; - parentSessionKey?: string; - sessionScope?: SessionScope; - storePath?: string; - statusChannel: string; - provider: string; - model: string; - contextTokens?: number; - resolvedThinkLevel?: ThinkLevel; - resolvedFastMode?: boolean; - resolvedHarness?: string; - resolvedVerboseLevel: VerboseLevel; - resolvedReasoningLevel: ReasoningLevel; - resolvedElevatedLevel?: ElevatedLevel; - resolveDefaultThinkingLevel: () => Promise; - isGroup: boolean; - defaultGroupActivation: () => "always" | "mention"; - mediaDecisions?: MediaUnderstandingDecision[]; - taskLineOverride?: string; - skipDefaultTaskLookup?: boolean; - primaryModelLabelOverride?: string; - modelAuthOverride?: string; - activeModelAuthOverride?: string; - includeTranscriptUsage?: boolean; -}; +import type { BuildStatusTextParams } from "./status-text.types.js"; +export type { BuildStatusTextParams } from "./status-text.types.js"; const USAGE_OAUTH_ONLY_PROVIDERS = new Set([ "anthropic", diff --git a/src/status/status-text.types.ts b/src/status/status-text.types.ts new file mode 100644 index 00000000000..dba9bb74949 --- /dev/null +++ b/src/status/status-text.types.ts @@ -0,0 +1,38 @@ +import type { + ElevatedLevel, + ReasoningLevel, + ThinkLevel, + VerboseLevel, +} from "../auto-reply/thinking.js"; +import type { SessionEntry, SessionScope } from "../config/sessions.js"; +import type { OpenClawConfig } from "../config/types.openclaw.js"; +import type { MediaUnderstandingDecision } from "../media-understanding/types.js"; + +export type BuildStatusTextParams = { + cfg: OpenClawConfig; + sessionEntry?: SessionEntry; + sessionKey: string; + parentSessionKey?: string; + sessionScope?: SessionScope; + storePath?: string; + statusChannel: string; + provider: string; + model: string; + contextTokens?: number; + resolvedThinkLevel?: ThinkLevel; + resolvedFastMode?: boolean; + resolvedHarness?: string; + resolvedVerboseLevel: VerboseLevel; + resolvedReasoningLevel: ReasoningLevel; + resolvedElevatedLevel?: ElevatedLevel; + resolveDefaultThinkingLevel: () => Promise; + isGroup: boolean; + defaultGroupActivation: () => "always" | "mention"; + mediaDecisions?: MediaUnderstandingDecision[]; + taskLineOverride?: string; + skipDefaultTaskLookup?: boolean; + primaryModelLabelOverride?: string; + modelAuthOverride?: string; + activeModelAuthOverride?: string; + includeTranscriptUsage?: boolean; +};