Skip to content

sync: background job runtime, agent/plugin manager plugins, slimmer prompts - #113

Merged
Luhaozhu merged 2 commits into
mainfrom
sync/ce-2026-08-17
Aug 17, 2026
Merged

sync: background job runtime, agent/plugin manager plugins, slimmer prompts#113
Luhaozhu merged 2 commits into
mainfrom
sync/ce-2026-08-17

Conversation

@Luhaozhu

Copy link
Copy Markdown
Contributor

Syncs the community edition with the current upstream tree. 97 files, no binaries.

This supersedes #111 and #112 — it carries everything they had plus the workflow-mode
fix on the job wake-up path, so those two are being closed in favour of this one.

Background job runtime (workflow mode)

  • Adds the job subsystem: orchestration/job_runtime.py, job_wakeup.py,
    core/services/job_service.py, the run_job tool, the /v1/jobs and
    /v1/internal/jobs routes, and the Job model.
  • Wires it up on the CE side, which was the missing half. The tool was already
    registered and the prompts already mentioned it, but the routers were absent from
    CE_ROUTERS, the model was not exported from core/db/models/__init__.py, and no
    migration created the tables — so submitting a job answered 404 on the first
    callback and died on the spot. Adds ce_0006_job_runtime.py; the migration chain
    still has a single head.
  • Runs jobs in the background by default, resolves the callback base URL instead of
    hard-coding the host, reaps orphaned jobs, and keeps timestamps timezone-aware.
  • Carries workflow_chat through the wake-up round. The wake-up message tells the
    model it can run_job(action='resume'), but the wake-up path built its context from
    scratch and dropped workflow mode, so run_job was not on the tool surface and the
    model pulled every work item back into the main loop. Chat metadata is the source of
    truth, so non-workflow chats are not switched on by accident. Covered by
    tests/orchestration/test_job_wake_mode.py (terminal wake inherits the mode,
    progress wake inherits the mode, non-workflow chats stay off).
  • Job progress strip above the composer, with abnormal terminal states re-fetched on
    mount so a job that died while the page was closed is still reported instead of
    looking like it never ran.

Agent manager and plugin manager plugins

  • Two new marketplace plugins that move sub-agent and plugin CRUD into the chat:
    agent_manager_mcp / plugin_manager_mcp servers plus the agent-manager and
    plugin-manager bundles.
  • Their route descriptions are written as prompt text rather than marketplace copy,
    since they ship on every turn.

Prompt and tool-schema slimming

  • Default system prompts 5.3k → 4.0k characters, code_exec 5.3k → 4.4k, with all
    rules preserved.
  • 14 MCP tool descriptions compressed: tool schemas 13.8k → 10.8k tokens (−21.5%),
    roughly 3k tokens of static prefill saved per request.

Reliability and UI

  • Reverts the process-level search rate limit, which throttled the whole search MCP
    down to one call per minute.
  • Fixes the sandbox session lock across event loops, so keep-alive no longer fails
    silently and leaves jobs stuck in running.
  • Sidebar chat list supports drag-to-reorder; the manual order takes precedence over
    updatedAt and follows the account.
  • Mobile pass: safe areas, iOS zoom, touch targets, dark top bar.

Verification

  • CE derived tree built from upstream with scripts/build_ce.py; brand gate, required
    runtime files gate, forbidden artefacts gate and binary allowlist all pass.
  • CE_ROUTERS — all 43 module names resolve to a file under api/routes/v1/.
  • core/db/models/__init__.py — all 15 submodule imports resolve.
  • Alembic — 6 migrations, single head ce_0006, job tables created.

Luhaozhu added 2 commits August 17, 2026 11:22
…rompts

Sync the community edition with the current upstream tree.

Background job runtime (workflow mode)
- Add the job subsystem: `orchestration/job_runtime.py`, `job_wakeup.py`,
  `core/services/job_service.py`, the `run_job` tool, the `/v1/jobs` and
  `/v1/internal/jobs` routes, and the `Job` model.
- Wire it up on the CE side, which was the missing half: register the routers in
  `CE_ROUTERS`, export the model from `core/db/models/__init__.py`, and create the
  tables in a new migration `ce_0006_job_runtime.py`. Without these three, the tool
  was registered but the first callback answered 404 and the job died on the spot.
- Run jobs in the background by default, resolve the callback base URL instead of
  hard-coding the host, reap orphaned jobs, and keep timestamps timezone-aware.
- Carry `workflow_chat` through the wake-up round. The wake-up message tells the
  model it can `run_job(action='resume')`, but the wake-up path built its context
  from scratch and dropped workflow mode, so `run_job` was not on the tool surface
  and the model pulled every work item back into the main loop. The chat metadata is
  the source of truth here, so non-workflow chats are not switched on by accident.
- Job progress strip above the composer, with abnormal terminal states re-fetched on
  mount so a job that died while the page was closed is still reported.

Agent manager and plugin manager plugins
- Two new marketplace plugins that move sub-agent and plugin CRUD into the chat:
  `agent_manager_mcp` / `plugin_manager_mcp` servers plus the `agent-manager` and
  `plugin-manager` bundles.
- Route descriptions are written as prompt text, not marketplace copy — they ship on
  every turn.

Prompt and tool-schema slimming
- Default system prompts 5.3k to 4.0k characters, `code_exec` 5.3k to 4.4k, with all
  rules preserved.
- 14 MCP tool descriptions compressed: tool schemas 13.8k to 10.8k tokens (-21.5%),
  about 3k tokens of static prefill saved per request.

Reliability and UI
- Revert the process-level search rate limit; it throttled the whole search MCP down
  to one call per minute.
- Fix the sandbox session lock across event loops, so keep-alive no longer fails
  silently and leaves jobs stuck in `running`.
- Sidebar chat list supports drag-to-reorder, with the manual order taking precedence
  over `updatedAt` and following the account.
- Mobile pass: safe areas, iOS zoom, touch targets, dark top bar.
Two follow-ups to the sync commit.

ce_0006 broke every fresh install
- `ce_0001` builds the baseline with `ce_create_all`, straight from the SQLAlchemy
  models, and the job tables are now part of the CE metadata. So by the time the
  chain reaches `ce_0006` on a **new** database, `jobs` / `job_items` / `job_calls`
  already exist and the unconditional `op.create_table` dies with
  `table jobs already exists`. Fresh installs failed; only upgrades of older
  databases worked.
- `ce_0005` already documents this invariant ("an unconditional add_column would
  fail on every new deployment"). `ce_0006` is the first migration in the CE chain
  to use an explicit `create_table`, so it was the first to trip over it.
- Each table is now created only when the inspector says it is absent, and
  `downgrade()` is guarded the same way — on a fresh database this migration creates
  nothing, so it must not drop anything either.
- Verified on SQLite, both directions: `alembic upgrade head` on a fresh database
  now completes at `ce_0006` with the three tables present; and a simulated legacy
  database (upgraded to `ce_0005`, job tables dropped) has `ce_0006` create the
  tables and their indexes.

Workflow-mode hint
- The workflow prompt section still told the model to pass `wait=true`, which
  cancelled out the switch to running jobs in the background by default. Covered by
  `test_workflow_hint_consistency.py`.
@Luhaozhu
Luhaozhu merged commit 4959f1f into main Aug 17, 2026
5 checks passed
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.

1 participant