♻️ refactor: implement SkillResolver, BaseSystemRoleProvider, and agent document injection pipeline#13315
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@nekomeowww - This is a backend/agent-runtime refactor implementing SkillResolver architecture. Please take a look. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #13315 +/- ##
==========================================
+ Coverage 66.76% 66.83% +0.07%
==========================================
Files 1889 1891 +2
Lines 151446 151326 -120
Branches 14506 14520 +14
==========================================
+ Hits 101112 101142 +30
+ Misses 50222 50065 -157
- Partials 112 119 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 17c299894f
ℹ️ 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".
| identifier: s.identifier, | ||
| name: s.name, |
There was a problem hiding this comment.
Include DB skill content in operation skill metadata
This refactor now auto-activates any skill whose identifier is in enabledPluginIds, but DB skills are still emitted without content. When a user/market skill is enabled in agentConfig.plugins, SkillResolver will mark it activated; then SkillContextProvider drops it from <available_skills> (because it is activated) and also cannot inject it (because content is missing), so the skill disappears from the prompt and becomes unusable. Add s.content here (or avoid activating skills that have no content).
Useful? React with 👍 / 👎.
Introduces a two-layer skill resolution architecture mirroring ToolsEngine + ToolResolver: - SkillEngine (assembly layer): accepts raw skills + enableChecker, outputs OperationSkillSet - SkillResolver (resolution layer): merges operation + step delta + accumulated activations Key changes: - Add SkillResolver, OperationSkillSet, StepSkillDelta, ActivatedStepSkill types - Enhance SkillEngine with enableChecker and generate() method - Wire SkillResolver into RuntimeExecutors call_llm - Replace manual skillMetas assembly in aiAgent with SkillEngine.generate() - Update client-side skillEngineering to use SkillEngine + enableChecker - Add activatedStepSkills to AgentState for step-level skill accumulation Fixes: agent-browser content injected into non-desktop scenarios (Discord bot) due to missing filterBuiltinSkills call in aiAgent LOBE-6410 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… documents server-side - Create @lobechat/agent-templates package with types, templates, and registry - Move DocumentLoadPosition, DocumentLoadFormat, DocumentLoadRule, etc. to new package - Move claw templates (AGENTS, BOOTSTRAP, IDENTITY, SOUL) with .md file imports - Add BOOTSTRAP.md as new onboarding template (priority 1, system-append) - Fix template positions: AGENTS→before-system, IDENTITY/SOUL→system-append - Update database package to re-export from @lobechat/agent-templates - Migrate all consumers to import directly from @lobechat/agent-templates - Add agent documents injection in server-side RuntimeExecutors (was missing) - Support -p CLI flag in devStartupSequence for port configuration Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ates Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
8572407 to
eab8756
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Stop re-exporting template/templates from database — consumers import directly from @lobechat/agent-templates. Keep types.ts re-exports for internal database code only. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…pend pattern All providers that append to the system message now inherit from BaseSystemRoleProvider and only implement buildSystemRoleContent(). The base class handles find-or-create and join logic. Migrated providers: - EvalContextSystemInjector - BotPlatformContextInjector - SystemDateProvider - ToolSystemRoleProvider - HistorySummaryProvider - SkillContextProvider Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…cted hook Add onInjected() callback to BaseSystemRoleProvider so subclasses can update pipeline metadata after successful injection. Also add raw-md plugin to context-engine vitest config for .md imports. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ionals in MessagesEngine All providers now accept an `enabled` config field. MessagesEngine pipeline is a flat array with no spread conditionals — each provider is always instantiated and uses `enabled` to skip internally. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove numbered prefixes, keep descriptive comments for each provider. Only phase headers use separator blocks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…arget Phase 1: History Truncation Phase 2: System Message Assembly (all BaseSystemRoleProvider) Phase 3: Context Injection (before first user message, BaseFirstUserContentProvider) Phase 4: User Message Augmentation (last user message injections) Phase 5: Message Transformation (flatten, template, variables) Phase 6: Content Processing & Cleanup (multimodal, tool calls, cleanup) Moved SkillContext, ToolSystemRole, HistorySummary from Phase 3 to Phase 2 since they append to system message, not user context. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…jectors - AgentDocumentSystemInjector (Phase 2): before-system, system-append, system-replace - AgentDocumentContextInjector (Phase 3): before-first-user - AgentDocumentMessageInjector (Phase 4): after-first-user, context-end Shared utilities (filterByRules, formatDocument, sortByPriority) extracted to AgentDocumentInjector/shared.ts. Old monolithic injector removed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…jectors - AgentDocumentBeforeSystemInjector: prepends as separate system message (before-system) - AgentDocumentSystemAppendInjector: appends to system message (system-append) - AgentDocumentSystemReplaceInjector: replaces entire system message (system-replace) Each has distinct semantics and correct pipeline placement: - BeforeSystem → before SystemRoleInjector - SystemAppend → after HistorySummary (end of Phase 2) - SystemReplace → last in Phase 2 (destructive) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add AgentDocumentsManifest to defaultToolIds - Add hasAgentDocuments rule in server createServerAgentToolsEngine - Query agent documents in AiAgentService.execAgent to determine flag - Pattern matches KnowledgeBase auto-enable via enableChecker rules Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
❤️ Great PR @arvinxx ❤️ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world. |
Summary
ToolsEngine+ToolResolverBaseSystemRoleProviderbase class to unify system message assemblyAgentDocumentInjectorinto 5 position-based injectors for correct pipeline placement@lobechat/agent-templatespackage for agent document templatesRuntimeExecutors(was missing)lobe-agent-documentstool when agent has documentsBOOTSTRAP.mdtemplate for first-run agent onboardingKey Changes
SkillResolver
SkillResolver,OperationSkillSet,StepSkillDelta,ActivatedStepSkilltypes in@lobechat/context-engineSkillEnginewithenableCheckerandgenerate()methodSkillResolverintoRuntimeExecutorscall_llmskillMetasassembly inaiAgentwithSkillEngine.generate()agent-browsercontent (~1.5k tokens) being injected into non-desktop scenariosBaseSystemRoleProvider
buildSystemRoleContent()+ optionalonInjected()for metadataAgent Document Injection Pipeline
AgentDocumentInjectorinto 5 injectors:AgentDocumentBeforeSystemInjector(before-system) → Phase 2 startAgentDocumentSystemAppendInjector(system-append) → Phase 2 endAgentDocumentSystemReplaceInjector(system-replace) → Phase 2 endAgentDocumentContextInjector(before-first-user) → Phase 3AgentDocumentMessageInjector(after-first-user, context-end) → Phase 4RuntimeExecutorsnow fetches and injects agent documents (was missing)MessagesEngine Pipeline Reorganization
BaseSystemRoleProvider)enabledfield — no spread conditionals in pipeline@lobechat/agent-templates Package
@lobechat/databaseinto standalone packageDocumentLoadPosition,DocumentLoadFormat, etc.), templates, and registry.mdfile imports for contentBOOTSTRAP.mdonboarding templateAuto-enable Agent Documents Tool
AgentDocumentsManifesttodefaultToolIdscreateServerAgentToolsEngineenables tool viahasAgentDocumentsruleAiAgentServicequeries agent documents to determine flagFixes LOBE-6410
Test plan
🤖 Generated with Claude Code