API Reference¶
Auto-generated from source docstrings.
Config¶
Pydantic configuration models for mattermind.
AgentConfig
¶
Bases: BaseModel
Agent loop behaviour settings.
Source code in src/mattermind/config/models.py
AppConfig
¶
Bases: BaseModel
Root application configuration.
Source code in src/mattermind/config/models.py
LLMConfig
¶
Bases: BaseModel
LLM provider settings.
Source code in src/mattermind/config/models.py
LoggingConfig
¶
MattermostConfig
¶
Bases: BaseModel
Mattermost connection settings.
Auth is either a personal access token (token) or a login/password pair.
Exactly one of the two must be provided.
Source code in src/mattermind/config/models.py
OutputConfig
¶
Bases: BaseModel
Output rendering settings.
Source code in src/mattermind/config/models.py
Mattermost Client¶
Async Mattermost REST API v4 client with retries and rate limiting.
MattermostAPIError
¶
Bases: Exception
Raised when the Mattermost API returns an error response.
Source code in src/mattermind/mattermost/client.py
MattermostClient
¶
Async HTTP client for Mattermost REST API v4.
Usage::
async with MattermostClient(config) as client:
hits = await client.search_posts(team_id, "incident", None, 20)
Source code in src/mattermind/mattermost/client.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
get_channel(channel_id)
async
¶
Fetch channel metadata by ID.
get_my_teams()
async
¶
Return all teams the current user belongs to.
get_team_id(team_name_or_id)
async
¶
Resolve a team name or ID to a team ID string.
Source code in src/mattermind/mattermost/client.py
get_thread(post_id)
async
¶
Fetch the complete thread containing post_id.
Source code in src/mattermind/mattermost/client.py
get_user(user_id)
async
¶
search_posts(team_id, query, channel_id=None, per_page=20)
async
¶
Full-text search for posts within a team.
Source code in src/mattermind/mattermost/client.py
validate_connection()
async
¶
Return True if the token is valid and the server is reachable.
Agent¶
Main agentic loop that drives tool calling and answer generation.
AgentLoop
¶
Orchestrates the LLM + tool-calling loop to answer a user's question.
Source code in src/mattermind/agent/loop.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
run(question, on_status=None)
async
¶
Run the agentic loop for a given question and return AskResult.
Source code in src/mattermind/agent/loop.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
Tool definitions and execution for the Mattermind agent.
execute_tool(tool_name, tool_args, client, team_id, state, config, mm_url, mm_team)
async
¶
Dispatch a tool call and return a JSON string result.
All errors are caught and returned as JSON error objects so the LLM can decide how to proceed rather than crashing the loop.
Source code in src/mattermind/agent/tools.py
parse_post_id_from_permalink(url)
¶
Extract the post ID from a Mattermost permalink URL.
Returns the post_id string, or None if the URL is not a valid permalink.
Source code in src/mattermind/agent/tools.py
Mutable agent state shared across the agentic loop iterations.
AgentState
dataclass
¶
Tracks all mutable state during an agent run.
Source code in src/mattermind/agent/state.py
explored_threads = field(default_factory=list)
class-attribute
instance-attribute
¶
Metadata for the "Threads explored" section. Each entry:
incomplete = False
class-attribute
instance-attribute
¶
True if the run was terminated early (budget / iteration limit).
link_depth = field(default_factory=dict)
class-attribute
instance-attribute
¶
Maps post_id -> depth at which it was discovered (0 = direct search hit).
threads_fetched = 0
class-attribute
instance-attribute
¶
How many mm_get_thread calls succeeded.
token_usage = field(default_factory=TokenUsage)
class-attribute
instance-attribute
¶
Cumulative token usage across all LLM calls.
tool_calls_made = 0
class-attribute
instance-attribute
¶
Total number of tool calls dispatched.
visited_post_ids = field(default_factory=set)
class-attribute
instance-attribute
¶
Post IDs of threads we have already fetched — prevents re-fetching.
UI¶
Rich rendering helpers for mattermind output.
render_answer(console, markdown_text, fmt='markdown')
¶
Render the final LLM answer in the chosen format.
Source code in src/mattermind/ui/renderer.py
render_banner(console)
¶
Render ASCII art banner with a colour gradient.
Source code in src/mattermind/ui/renderer.py
render_query_panel(console, query)
¶
Render a panel showing the user's question.
Source code in src/mattermind/ui/renderer.py
render_status(console, message)
¶
render_summary(console, result, show_tokens=True, show_timings=True)
¶
Render a compact summary panel with run statistics.
Source code in src/mattermind/ui/renderer.py
render_thread_tree(console, explored_threads)
¶
Render a rich tree listing every explored thread with clickable links.
Source code in src/mattermind/ui/renderer.py
Beautiful error rendering via Rich panels.
error_panel(console, title, message, hint=None)
¶
Render a red error panel with an optional hint line.