Repository navigation
refactor(agents): split AgentSession responsibilities - #107948
Conversation
9b31302 to
81a0ef1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 81a0ef1b2d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| private baseSystemPromptOptions!: BuildSystemPromptOptions; | ||
| private exactBaseSystemPrompt: string | undefined; | ||
|
|
||
| export class AgentSession extends AgentSessionTree { |
There was a problem hiding this comment.
Keep AgentSession methods in SDK baseline
When the public openclaw/plugin-sdk/agent-sessions surface is regenerated, src/plugin-sdk/api-baseline.ts prints only a class declaration's direct declaration.members and does not flatten inherited members. After this split, the exported AgentSession class directly declares only the constructor and inherits all user-facing methods from the non-entrypoint AgentSessionTree, so the updated SDK hash blesses a baseline/docs surface that no longer records prompt, compact, setModel, etc.; future changes to those public methods can drift without the plugin SDK API check noticing. Please either keep the public facade members represented here or update the API baseline generator/export shape before accepting the new hash.
Useful? React with 👍 / 👎.
15acb7f to
0f3b3f4
Compare
20e368d to
17ccc18
Compare
17ccc18 to
b7dda74
Compare
b7dda74 to
40435eb
Compare
|
Merged via squash.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 40435ebd0c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return false; | ||
| } | ||
|
|
||
| if (this.isRetryableError(msg) && (await this.prepareRetry(msg))) { |
There was a problem hiding this comment.
Move retry hooks above the prompting layer
When this commit is type-checked, AgentSessionPrompting only extends AgentSessionBase, but the retry and compaction hooks it calls here are introduced later in subclasses (AgentSessionExecution and AgentSessionCompaction). That means this.isRetryableError, this.prepareRetry, and the later this.checkCompaction/flushPendingBashMessages calls are not members of this class, so the split breaks the TS build unless these hooks are declared on an ancestor/abstract interface or the inheritance order is changed.
Useful? React with 👍 / 👎.
What Problem This Solves
AgentSessionhad grown to 3,337 lines in one module, mixed unrelated responsibilities, and required a grandfathered max-lines suppression. That made focused review and maintenance harder.Why This Change Was Made
Split session behavior into focused internal layers for base lifecycle/events, prompting, models, inspection, compaction, extensions, execution, and tree operations. Extract shared public types and utilities, preserve the existing
AgentSessionentrypoint and behavior, consolidate repeated text/model-switch helpers, and remove the max-lines suppression.AI-assisted. Maintainer-requested refactor; no linked issue.
User Impact
No user-visible behavior change. Maintainers get smaller responsibility-focused modules and a clean max-lines gate.
Evidence
check:changed.origin/main. Changed-file lint is clean.