Documentation Index
Fetch the complete documentation index at: https://cognis.vasanth.xyz/llms.txt
Use this file to discover all available pages before exploring further.
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
| Field | Value |
|---|---|
| Latest version | 0.3 |
| docs.rs | docs.rs/cognis-macros |
| Repo path | crates/cognis-macros |
#[cognis::tool]
Attribute macro that turns anasync fn into an Arc<dyn Tool>-producing function.
| Attribute | Default | Effect |
|---|---|---|
name = "..." | fn name | Tool name as the model sees it. |
description = "..." | fn doc-comment | Description as the model sees it. |
return_direct = true/false | false | If true, the tool’s output becomes the final response (skip the next model turn). |
crate_path = "..." | cognis_core | Override for renamed re-export paths. |
| Attribute | Effect |
|---|---|
#[schema(range(min = 0, max = 100))] | Numeric bounds. |
#[schema(length(min = 1, max = 200))] | String / Vec length. |
#[schema(pattern("regex"))] | Regex. |
#[schema(enum_values("low", "medium", "high"))] | Enum. |
#[schema(format("email"))] | JSON Schema format. |
#[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(...)] | Behavior |
|---|---|
last_value (default) | self.field = update.field |
append | self.field.extend(update.field) |
add | self.field += update.field |
merge | deep-merge JSON |
- 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.