Skip to main content
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 an async fn into an Arc<dyn Tool>-producing function.
Attributes: 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.
Reducer options: The macro produces:
  • A struct MyStateUpdate mirroring 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 through cognis_core (and through the umbrella cognis::prelude), so:
If you have your own crate that vends the derives under a different path, set crate_path = "your_crate" on the tool macro.

See also

Tools

User guide for #[cognis::tool].

Graph state

User guide for GraphStateV2.