cognis-macros is the proc-macro crate. It exists so the rest of the workspace can use derives without dragging proc-macro infrastructure into every dependency. You don’t normally depend on this directly — cognis-core re-exports the derives, and cognis re-exports them through that.
Crate metadata
#[cognis::tool]
Attribute macro that turns anasync fn into an Arc<dyn Tool>-producing function.
Schema validators on fn arguments:
These emit both runtime validation and
#[schemars(...)] annotations on the generated args struct, so the model sees them in the JSON Schema.
The macro can also wrap an impl block containing exactly one #[tool]-marked async method — useful when the tool struct holds shared config (HTTP client, DB pool):
#[derive(GraphStateV2)]
Generates a sibling<Name>Update struct and an impl GraphState for <Name> from a state struct annotated with per-field #[reducer(...)] attributes.
The macro produces:
- A struct
MyStateUpdatemirroring the fields. impl GraphState for MyState { type Update = MyStateUpdate; fn apply(&mut self, u: MyStateUpdate) { /* per reducer */ } }.
#[derive(GraphState)] is the older, slightly different shape; new code should use GraphStateV2.
When to import directly
You usually shouldn’t. The derives are re-exported throughcognis_core (and through the umbrella cognis::prelude), so:
crate_path = "your_crate" on the tool macro.
See also
Tools
User guide for
#[cognis::tool].Graph state
User guide for
GraphStateV2.