Repository navigation
feat!: add capabilities & replace legacy message filters - #28
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
67c1426 to
756db56
Compare
e681878 to
6a8dab6
Compare
ref ENG-996 - Added `thread_capabilities` to `chat.start` for overriding agent capabilities for the thread's lifetime. - Introduced `message_scope` in `chat.start` and `chat.send` to enable/disable capabilities or narrow their allowlist for individual messages. - Removed deprecated parameters: `source_ids`, `document_ids`, and `disabled_tools` in favor of the new capabilities structure. - Updated documentation and examples to reflect these changes, including new usage patterns for capabilities.
6a8dab6 to
368b7e6
Compare
|
/merge |
|
Success! Fast forwarded dev to eng-996-introduce-the-core-capabilities-model-with-backward! |
Summary
Adds capabilities to
chat.startandchat.send, including amemorycapability, andremoves the legacy message filters and the
memory_namespaceargument they replace.The keyword name tells you the scope:
thread_capabilities(startonly): overrides some of the agent's capabilities forthis thread, frozen for its lifetime. This is also where the memory bag is set.
message_scope(startandsend): turns a capability on or off, or narrows itsallowlist, for one message. Sent as
message.scope.Every capability is an explicit object with a required activation, and every scope is an
explicit object with a required
enabled. There are no shortcuts such asweb=Trueorweb="on_request".Design
WebCapability,IndexedDocumentsCapability,McpCapability,SkillsCapability,ImageGenerationCapability,VideoGenerationCapability,MusicGenerationCapability,MemoryCapability. Message level classes:WebScope,IndexedDocumentsScope,McpScope,ImageGenerationScope,VideoGenerationScope,MusicGenerationScope. They are distinct classes, so pyright rejectsweb=ImageGenerationCapability(...).activationandenabledare always required. Skills accept"always"or"never"only.
MessageScopehas noskillsand nomemory, like the API.source_ids,document_ids,connections,include) default toALL(thestring
"*", no restriction) on capabilities and on scopes. PassingALLexplicitly isequivalent to omitting the filter.
None,[]and a"*"inside a list raiseInvalidParamsbefore any request is sent, and so does a filter combined withactivation="never"orenabled=False."never"sends only{"activation": "never"}, a disabled scope only{"enabled": false}. This is done withmode="wrap"serializers that edit the defaultoutput.
MemoryCapability(activation="always", namespace=...)sets the thread's memory bag (1 to 128 characters),MemoryCapability(activation="never")runs the thread without memory.alwaysrequiresa namespace and
neverrefuses one. Without amemoryentry, the thread uses theagent's namespace, or runs without memory if the agent has none. The bag is frozen at
start: a follow-up cannot change it.message.scope. Under the keymessage.capabilitiesthe APIsilently ignores it, so this matters.
thread_capabilitiesdoes not exist onchat.send, so the API's 422 for a follow-upoverride cannot be triggered.
thread does not have, switching off what is already off) stay server side and surface as
a 422
APIError.ValidationErrortoInvalidParamsconversion is amode="wrap"model validatoron a private
_StrictModelbase, so pyright keeps the per-field__init__signature.AgentCapabilitiesis reusable as is by a futureclient.agents./agentsis notcovered here: it returns 403 with an API key.
Breaking changes
This is a major release (1.0.0). Removed from
chat.start/chat.sendandHumanMessage:source_ids,document_ids,disabled_tools, andDisablableTool. TheAPI refuses to mix them with capabilities. Removed from
chat.startandStartChatOptions:memory_namespace, now a capability.disabled_tools=["web"]message_scope=MessageScope(web=WebScope(enabled=False))disabled_tools=["company_documents"]MessageScope(indexed_documents=IndexedDocumentsScope(enabled=False))disabled_tools=["mcp:*"]MessageScope(mcp=McpScope(enabled=False))disabled_tools=["mcp:notion"]MessageScope(mcp=McpScope(enabled=True, connections=[<connections to keep>]))source_ids=[101]MessageScope(indexed_documents=IndexedDocumentsScope(enabled=True, source_ids=[101]))document_ids=[...]IndexedDocumentsScope(enabled=True, document_ids=[...])memory_namespace="support-bot"thread_capabilities=AgentCapabilities(memory=MemoryCapability(activation="always", namespace="support-bot"))Also in this PR
examples/11_capabilities.py(it follows10_max_steps.py).[1.0.0]section with the migration table. The version bumpis left to
uv run invoke release --major.Test plan
uv run invoke code.all(ruff, pyright strict, pytest, 100% coverage)"*"kept,neverandenabled=Falsesend only theswitch, no
Nonekeys), local validation errors, memory namespace rules, requestbodies for
startandsend(message.scope),memory_namespaceno longeraccepted
playground/test_scenario, not part ofthe PR): every capability and scope observed through the agent's own scopes block and
tool list, follow-up scopes lasting one message, the server's 422 policy errors,
saved agents combined with thread overrides, and memory routing checked with real
writes through
client.memory