Skip to content

fix(aistio): create agent_shares table and expose tierForCurrentUser (#2977) - #2978

Open
shynemo wants to merge 3 commits into
agentscope-ai:mainfrom
shynemo:2977-fix-agent-shares-tier
Open

fix(aistio): create agent_shares table and expose tierForCurrentUser (#2977)#2978
shynemo wants to merge 3 commits into
agentscope-ai:mainfrom
shynemo:2977-fix-agent-shares-tier

Conversation

@shynemo

@shynemo shynemo commented Sep 4, 2026

Copy link
Copy Markdown

Summary

Fixes #2977.

The Agent sharing feature in the agentscope-service aistiod control plane reads/writes a table named agent_shares, but the startup schema migration never created it — only the legacy, unused resource_shares table was. This causes Share operations (and any agent-list visibility query that joins agent_shares) to fail with relation "agent_shares" does not exist (SQLSTATE 42P01).

A closely related defect: the console AgentLayout gates every Agent detail tab (Workspace/Skills/Tools/Subagents/Channels/Settings, all minTier: 'RUN') on tierForCurrentUser, but the Go agent API never returned that field, so the whole tab strip was hidden — even for the agent owner.

Changes

  • aistio/internal/product/migrate.go
    • Add the agent_shares CREATE TABLE migration (owner_id, agent_id, grantee_type, grantee_id, tier, created_at), with a unique constraint on (owner_id, agent_id, grantee_type, grantee_id) matching the addShare ON CONFLICT clause, plus lookup indexes. The migration is idempotent (CREATE TABLE IF NOT EXISTS), so existing deployments pick it up on aistiod restart — no data-volume reset required.
    • Mark resource_shares as a legacy table with no readers/writers (doc comment only).
  • aistio/internal/product/handlers_agents.go
    • Return tierForCurrentUser: owners resolve to EDIT; other users get their highest CLONE/RUN/EDIT grant from agent_shares (a direct USER grant or a WORKSPACE '*' grant).
    • Scope listAgents/getAgent to agents the caller owns or has a share for; load cross-owner shared agents via loadSharedAgent with a tier check.
  • service-scheduler/.../worker/HandsWorkerMain.java
    • Fix the javadoc usage example: the self-hosted Hands worker authenticates with an environment key issued as ek_<id> (product.shortID("ek_")), not ebk_.

Verification

  • go build ./... && go vet ./internal/product/ && go test ./internal/product/ — pass.
  • The added table columns/constraint were checked against every SQL site that touches agent_shares: listShares/addShare/revokeShare (handlers_agent_extras.go), the admin user-deletion cascade (handlers_admin.go), and the visibility/tier queries (handlers_agents.go).
  • After deploying, restarting aistiod runs the idempotent migration (running cp schema migrationcp schema migration complete); the Agents page then loads, the detail tabs render, and Share list/add/revoke succeed.

Additional notes

  • resource_shares is left in place (not dropped) for compatibility with existing databases; it has no code readers or writers and is now documented as legacy.

shynemo and others added 3 commits September 4, 2026 12:28
…gentscope-ai#2977)

The agent share handlers (listShares/addShare/revokeShare) and the admin
user-deletion cascade all read and write the `agent_shares` table, but no
migration ever created it — only the legacy, unused `resource_shares`
table was. Once agent listing filtered visibility through `agent_shares`,
opening the Agents page failed with
`relation "agent_shares" does not exist (SQLSTATE 42P01)`.

- Add the `agent_shares` CREATE TABLE migration (owner_id, agent_id,
  grantee_type, grantee_id, tier, created_at, with a unique constraint on
  the share tuple matching the addShare ON CONFLICT clause) plus lookup
  indexes.
- Mark `resource_shares` as a legacy table that has no readers or writers.
- Return `tierForCurrentUser` from the agent API: owners resolve to EDIT;
  other users get their highest CLONE/RUN/EDIT grant from `agent_shares`
  (a direct USER grant or a WORKSPACE '*' grant). The console AgentLayout
  relies on this field to render the detail tabs, so without it the whole
  tab strip (Workspace/Skills/Tools/Subagents/Channels/Settings) was hidden.
- Scope listAgents/getAgent to agents the caller owns or has a share for,
  and load shared agents across owners via loadSharedAgent with a tier check.

Fixes agentscope-ai#2977

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The self-hosted Hands worker authenticates with an environment key issued
as `ek_<id>` (product.shortID("ek_")), not `ebk_`. Fix the javadoc usage
example so the documented --environment-key matches the issued key.

Ref agentscope-ai#2977

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@CLAassistant

CLAassistant commented Sep 5, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants