Skip to content

feat(agent): support dynamic skill visibility - #1285

Open
Voitamin wants to merge 2 commits into
LazyAGI:mainfrom
Voitamin:codex/skill-visibility
Open

Voitamin wants to merge 2 commits into
LazyAGI:mainfrom
Voitamin:codex/skill-visibility

Conversation

@Voitamin

Copy link
Copy Markdown

What

把 SkillManager 构造时的 Skill 列表拆成两个概念:

  • allowed_skills:权限/启用边界,运行中不可越过
  • skills:初始可见集合

新增:

  • expose_skills(ids):在当前 session 内动态把 allowed skill 加入可见
  • list_skill_metadata(scope='allowed'|'visible'):对外暴露 descriptor catalog(不含 SKILL.md 正文)
  • 动态 exposed 存 session-local workspace,session 结束自动清理,不跨会话泄漏
  • ReactAgent/LazyLLMAgentBase 支持传入预构建 skill_manager

Why

LazyMind 需要在 AgentLoop 前做候选筛选、Loop 内二次发现,但原 SkillManager 把「允许范围」和「当前可见范围」混为一谈,无法动态扩大可见范围。

Tests

  • test_skills.py + test_agent_base.py:allowed/visible 分离、aliases/tags 归一化、disable-model-invocation 不进 allowed、动态 expose 边界、Agent 接受预构建 manager(25 passed)
  • 既有 test_react_agent_with_skills 需下载 Qwen2.5-32B + ModelScope,与本次无关,本地 deselect

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 286514d8a0

ℹ️ 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".

Comment on lines +568 to +570
for key in resolved:
if key not in exposed:
exposed.append(key)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Refresh the model prompt after exposing skills

When expose_skills() is called after a ReactAgent has already been built, these newly appended keys never reach the model: FunctionCall eagerly evaluates skill_manager.build_prompt() when constructing its ChatPrompter (functionCall.py:90-94), and the once-wrapped agent build is not repeated. The manager's tools will accept the exposed skill, but the model-facing skill list remains unchanged, so the model cannot discover it; the prompter should resolve the skill prompt dynamically or be refreshed after exposure.

Useful? React with 👍 / 👎.

Comment on lines +559 to +561
workspace = lazyllm_locals['_lazyllm_agent'].setdefault('workspace', {})
exposed_by_manager = workspace.setdefault('_exposed_skills', {})
exposed = exposed_by_manager.setdefault(self._module_id, [])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve exposed skills for the entire agent session

When an agent invocation produces its final string, FunctionCall.forward() pops the entire workspace (functionCall.py:235-240), including _exposed_skills stored here. Thus exposing a skill once and invoking the same agent again within the same new_session silently revokes that skill, contrary to this API's documented session scope; store exposure outside the transient invocation workspace or explicitly preserve it during cleanup.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

感谢这个 PR 对 Skill progressive disclosure 的支持。allowed skills 和当前可用 Skill 的区分,以及运行过程中动态 expose Skill 的能力,为后续 LazyMind 支持数百个 Skill 提供了比较重要的底层能力。

架构上建议后续重点考虑以下几点:

  • 进一步拆分 SkillManager 的职责。 当前 SkillManager 同时承担 Skill 目录/元数据管理、可见状态、Prompt 渲染和 Skill 执行等职责。后续更适合拆分为共享的 SkillCatalog 和一次用户 Query 级别的 SkillRuntime,避免 Catalog 状态和运行时状态混在一起。
  • 避免 LazyMind 直接依赖具体的 SkillManager 实现。 LazyMind 需要的是“本次 Query 可以使用哪些 Skill、当前加载了哪些 Skill”的运行时能力,建议通过更稳定的 Runtime/Protocol 接口传递,避免当前 skill_manager 参数过早成为固定接口。
  • Skill 内容建议作为 Runtime Context 管理。 SkillRuntime 的生命周期是一整个用户 Query,覆盖内部多轮 LLM 请求和工具调用。get_skill 加载的完整 Skill 内容后续更适合作为 Runtime 临时上下文持续注入,而不是作为普通 Tool Result 写入 Conversation History。

This branch had an error being deployed

1 failed deployment
protected c513b7e7 Deployed Aug 20, 2026 by Voitamin via wait_approve #5300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants