Skip to content

Add profile-based LLM routing and tighten manager-worker dispatch tracking#2

Merged
RussellLuo merged 5 commits intoOpenCSGs:mainfrom
xxx7xxxx:dev
Apr 14, 2026
Merged

Add profile-based LLM routing and tighten manager-worker dispatch tracking#2
RussellLuo merged 5 commits intoOpenCSGs:mainfrom
xxx7xxxx:dev

Conversation

@xxx7xxxx
Copy link
Copy Markdown
Collaborator

@xxx7xxxx xxx7xxxx commented Apr 11, 2026

This PR introduces profile-based LLM routing for agents and tightens the manager-worker dispatch workflow.

  • Add named LLM profiles, agent profile selection, and a bot-scoped OpenAI-compatible bridge so boxes use server-resolved model settings instead of direct upstream config.
  • Improve manager runtime setup by seeding the dispatch skill/workspace, mounting generated PicoClaw config, and steering manager behavior toward the worker-dispatch fast path.
  • Strengthen manager_worker_api.py tracking so task handoff stays sequential and depends on both todo.json progress and in-room worker replies.
  • Update CLI, API, docs, UI output, and tests to match the new routing and dispatch flow.

Since the config has been enhanced, my local config looks like this. And I use https://github.com/router-for-me/CLIProxyAPI to leverage local codex as an API proxy.

# Generated by csgclaw onboard.

[server]
listen_addr = "0.0.0.0:18080"
advertise_base_url = ""
access_token = "your_access_token"

[llm]
default_profile = "codex-main"

[bootstrap]
manager_image = "ghcr.io/russellluo/picoclaw:2026.4.8.1"

[llm.profiles.codex-main]
provider = "llm-api"
base_url = "http://127.0.0.1:8317/v1"
api_key = "local"
model_id = "gpt-5.4"
reasoning_effort = "medium"

[llm.profiles.infini-glm5]
provider = "llm-api"
base_url = "https://cloud.infini-ai.com/maas/v1"
api_key = "sk-xxxx"
model_id = "glm-5"
reasoning_effort = ""

@xxx7xxxx xxx7xxxx requested a review from RussellLuo April 11, 2026 04:25
@RussellLuo
Copy link
Copy Markdown
Collaborator

Review suggestion 1

Recommended configuration structure:

  • Rename llm to models
  • Rename profile(s) to provider(s)
  • Allow multiple models under each provider
  • Let default point to "<provider>.<model>"
  • Is reasoning_effort required? If not, suggest adding it later instead of now
# Generated by csgclaw onboard.

[server]
listen_addr = "0.0.0.0:18080"
advertise_base_url = ""
access_token = "your_access_token"

[bootstrap]
manager_image = "ghcr.io/russellluo/picoclaw:2026.4.8.1"

[models]
default = "codex:gpt-5.4"

[models.providers.codex]
models = ["gpt-5.4"]
provider = "llm-api"
base_url = "http://127.0.0.1:8317/v1"
api_key = "local"

[models.providers.infini]
models = ["glm-5"]
base_url = "https://cloud.infini-ai.com/maas/v1"
api_key = "sk-xxxx"

References:

Review suggestion 2

csgclaw onboard --profile default --default-profile default --base-url <url> --api-key <key> --model-id <model> [--reasoning-effort <effort>]

TODO: need to discuss this part further. My understanding of onboard is somewhat different.

Review suggestion 3

Packaging "workspace/config/skills" for PicoClaw directly in CSGClaw will introduce significant complexity. In addition, we may support other xxClaw variants in the future, which would further increase the complexity.

For now, I will build an image using your latest skill.

TODO: need to discuss the follow-up optimization strategy together.

Review suggestion 4

Consider removing comments like the following:

// step 2.0 Parse global flags first, then dispatch the remaining args as one concrete command branch.

They are too detailed and numerous for inline comments. When needed, we can rely on AI to interpret them instead.

@xxx7xxxx xxx7xxxx force-pushed the dev branch 2 times, most recently from 011f209 to 7d2000a Compare April 13, 2026 02:05
@xxx7xxxx
Copy link
Copy Markdown
Collaborator Author

Suggestion 1

reasoning_effort is required for the OpenAI API since medium or below makes debugging time quicker. So I keep it with optional.

[server]
listen_addr = "0.0.0.0:18080"
advertise_base_url = ""
access_token = "your_access_token"

[bootstrap]
manager_image = "ghcr.io/russellluo/picoclaw:2026.4.8.1"

[models]
default = "codex.gpt-5.4"

[models.providers.codex]
base_url = "http://127.0.0.1:8317/v1"
api_key = "local"
models = ["gpt-5.4"]
reasoning_effort = "medium"

Review suggestion 2

Somehow I got your point (maybe). Just simplified it to :

csgclaw onboard --base-url <url> --api-key <key> --models <model[,model...]> [--reasoning-effort <effort>]

BTW, I think we can make the initialization steps (with interactions to ask users to type) to onboard in the main csgclaw if no config file is found. Is that a good idea to improve UX?

Review suggestion 3

Not get it, I need more context. But I strongly agree that we should be claw-insensitive.

Review suggestion 4

My bad, comments eliminated.

@xxx7xxxx xxx7xxxx force-pushed the dev branch 2 times, most recently from bf3a923 to 8e14a54 Compare April 13, 2026 08:14
Comment thread docs/api.md
- 服务端会根据 `bot_id` 对应 agent 的 `profile` 解析实际模型配置,并在响应中保留已解析快照字段
- box 内看到的是统一的 OpenAI 兼容接口;不会拿到宿主机上的真实上游 `api_key`

### `POST /api/bots/{bot_id}/llm/v1/chat/completions`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Who's this API meant for?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It is meant for the bot runtime inside the box, mainly PicoClaw manager/worker processes.

More precisely: it is CSGClaw’s internal OpenAI-compatible LLM bridge, so a bot can call a stable /v1/chat/completions endpoint while the server resolves the bot’s actual profile, model_id, and upstream credentials on its behalf.

We don't package workspace/skills/config for now, but we did the LLM bridge for:

  • exists to decouple the box runtime from real upstream model configuration.
  • give PicoClaw inside the box one stable OpenAI-compatible endpoint
  • let CSGClaw resolve the bot’s actual profile, model_id, and defaults on the server side
  • prevent exposing real upstream base_url and api_key inside the container
  • make per-agent model routing possible without changing PicoClaw (in next change, I want to introduce that every role/agent could have a different model)

@RussellLuo RussellLuo merged commit c88471d into OpenCSGs:main Apr 14, 2026
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