Integrations and domain reference
Kaggle HTTP integration with explicit authentication and bounded downloads.
(c) Mike Casale 2026. Licensed under the MIT License.
KaggleSettings
Bases: BaseSettings
Credentials read only when constructing a worker adapter.
A KAGGLE_API_TOKEN access token is preferred. The legacy
KAGGLE_USERNAME and KAGGLE_KEY pair remains supported.
Source code in agent_k/kaggle.py
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 | |
validate_credentials
validate_credentials() -> Self
Require one complete credential form before any request is attempted.
Source code in agent_k/kaggle.py
71 72 73 74 75 76 77 78 | |
KaggleAuth
Bases: Auth
Attach Kaggle credentials only to requests addressed to the Kaggle API host.
Downloads redirect to signed object-storage URLs. Scoping credentials by host keeps them out of those requests, including after a followed redirect.
Source code in agent_k/kaggle.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
auth_flow
auth_flow(request: Request) -> Generator[Request, Response]
Authorize a request when, and only when, it targets the Kaggle API host.
Source code in agent_k/kaggle.py
97 98 99 100 101 | |
KaggleAdapter
dataclass
Mission-scoped adapter using an injected HTTP client.
The caller owns and closes the client. Non-idempotent submission requests are never retried automatically; an uncertain receipt requires reconciliation.
Source code in agent_k/kaggle.py
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 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | |
platform_name
property
platform_name: str
Return the external platform identifier.
authenticate
async
authenticate() -> bool
Check credentials and fail immediately on rejected authentication.
Source code in agent_k/kaggle.py
182 183 184 185 186 187 188 | |
search_competitions
async
search_competitions(
categories: list[str] | None = None,
keywords: list[str] | None = None,
min_prize: int | None = None,
active_only: bool = True,
) -> AsyncIterator[Competition]
Yield supported competitions matching explicit discovery criteria.
Listing pages are read until one is empty, repeats earlier results, or the configured page limit is reached. Entries with unsupported metrics or malformed metadata are skipped rather than guessed.
Source code in agent_k/kaggle.py
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 | |
get_competition
async
get_competition(competition_id: str) -> Competition
Fetch exact metadata; unsupported or unknown metrics fail closed.
Source code in agent_k/kaggle.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
get_competition_by_url
async
get_competition_by_url(url: str) -> Competition
Resolve an exact Kaggle competition URL.
Source code in agent_k/kaggle.py
248 249 250 | |
get_leaderboard
async
get_leaderboard(
competition_id: str, *, limit: int = 100
) -> list[LeaderboardEntry]
Read leaderboard values without inventing missing scores or ranks.
Source code in agent_k/kaggle.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |
download_data
async
download_data(
competition_id: str, destination: str
) -> list[str]
Download files beneath a private destination using atomic replacement.
Source code in agent_k/kaggle.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
submit
async
submit(
competition_id: str, file_path: str, message: str = ""
) -> Submission
Upload one explicitly authorized submission, without automatic retries.
Source code in agent_k/kaggle.py
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
get_submission_status
async
get_submission_status(
competition_id: str, submission_id: str
) -> Submission
Return only scores actually reported by Kaggle.
Source code in agent_k/kaggle.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
validate_slug
validate_slug(value: str) -> str
Accept a competition slug or canonical Kaggle URL, rejecting other paths.
Source code in agent_k/kaggle.py
480 481 482 483 484 485 486 487 488 489 490 491 492 | |
parse_metric
parse_metric(value: str) -> EvaluationMetric
Normalize known metric names without an accuracy fallback.
Source code in agent_k/kaggle.py
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 | |
Model resolution for AGENT-K agents, performed only at execution time.
(c) Mike Casale 2026. Licensed under the MIT License.
create_devstral_model
create_devstral_model(
model_id: str = DEVSTRAL_MODEL_ID,
base_url: str | None = None,
) -> OpenAIChatModel
Create a Devstral model served by a local OpenAI-compatible LM Studio server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_id
|
str
|
Model identifier exposed by the local server. |
DEVSTRAL_MODEL_ID
|
base_url
|
str | None
|
Explicit server URL; the configured |
None
|
Returns:
| Type | Description |
|---|---|
OpenAIChatModel
|
A chat model bound to the local server. The configured API key is sent only |
OpenAIChatModel
|
to the configured server, never to an explicitly supplied URL. |
Source code in agent_k/providers.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
create_openrouter_model
create_openrouter_model(model_id: str) -> OpenAIChatModel
Create a model routed through OpenRouter's OpenAI-compatible API.
Source code in agent_k/providers.py
59 60 61 | |
get_model
get_model(model_spec: str) -> Model | str
Resolve one model specification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_spec
|
str
|
|
required |
Returns:
| Type | Description |
|---|---|
Model | str
|
A constructed model for AGENT-K provider prefixes, or the unchanged string |
Model | str
|
for Pydantic AI's own provider resolution. |
Source code in agent_k/providers.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
resolve_model
resolve_model(primary: str, *fallbacks: str) -> Model | str
Resolve an ordered model chain that fails over on provider API errors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
primary
|
str
|
Preferred model specification. |
required |
*fallbacks
|
str
|
Specifications tried in order when the preceding model's provider rejects or cannot serve a request. |
()
|
Returns:
| Type | Description |
|---|---|
Model | str
|
The single resolved model, or a |
Raises:
| Type | Description |
|---|---|
ValueError
|
The primary specification is empty. |
Failover covers provider API failures only. Output validation and tool retries stay with the model that produced the response.
Source code in agent_k/providers.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
is_devstral_model
is_devstral_model(model_spec: str) -> bool
Check if a model specification refers to Devstral.
Source code in agent_k/providers.py
112 113 114 | |
Search tool helpers for AGENT-K agents.
(c) Mike Casale 2026. Licensed under the MIT License.
build_kaggle_search_query
build_kaggle_search_query(query: str) -> str
Build a Kaggle-scoped web search query.
Source code in agent_k/search.py
29 30 31 | |
build_scholarly_query
build_scholarly_query(
topic: str, source: str = "all"
) -> str
Build a web search query for academic sources.
Source code in agent_k/search.py
34 35 36 37 38 39 40 41 42 43 | |
create_web_search_tool
create_web_search_tool(
*,
search_context_size: Literal[
"low", "medium", "high"
] = "medium",
user_location: WebSearchUserLocation | None = None,
blocked_domains: list[str] | None = None,
allowed_domains: list[str] | None = None,
max_uses: int | None = None,
) -> WebSearchTool
Create a WebSearchTool with explicit configuration.
Source code in agent_k/search.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
prepare_web_search
async
prepare_web_search(
ctx: RunContext[Any],
) -> WebSearchTool | None
Prepare WebSearchTool dynamically based on RunContext.
Source code in agent_k/search.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
create_web_fetch_tool
create_web_fetch_tool(
*,
allowed_domains: list[str] | None = None,
blocked_domains: list[str] | None = None,
max_uses: int | None = None,
enable_citations: bool = True,
max_content_tokens: int | None = None,
) -> WebFetchTool
Create a WebFetchTool with explicit configuration.
Source code in agent_k/search.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
prepare_web_fetch
async
prepare_web_fetch(
ctx: RunContext[Any],
) -> WebFetchTool | None
Prepare WebFetchTool dynamically based on RunContext.
Source code in agent_k/search.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
Public Pydantic AI tools for mission-scoped, durable memory records.
(c) Mike Casale 2026. Licensed under the MIT License.
MemoryDeps
dataclass
Directory owned by the current mission process.
Source code in agent_k/memory.py
21 22 23 24 25 | |
read_memory
read_memory(ctx: RunContext[MemoryDeps], name: str) -> str
Read an existing mission note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
RunContext[MemoryDeps]
|
Current mission dependencies. |
required |
name
|
str
|
A simple note identifier using letters, numbers, or hyphens. |
required |
Source code in agent_k/memory.py
31 32 33 34 35 36 37 38 39 | |
write_memory
write_memory(
ctx: RunContext[MemoryDeps], name: str, content: str
) -> str
Atomically write a bounded mission note.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
RunContext[MemoryDeps]
|
Current mission dependencies. |
required |
name
|
str
|
A simple note identifier using letters, numbers, or hyphens. |
required |
content
|
str
|
Evidence or reasoning to retain for this mission. |
required |
Source code in agent_k/memory.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
Protocol definitions for platform adapters.
(c) Mike Casale 2026. Licensed under the MIT License.
PlatformAdapter
Bases: Protocol
Protocol for platform adapters.
Platform adapters provide the interface between AGENT-K and competition platforms (e.g., Kaggle, DrivenData). Implementations must be async-first and handle authentication, rate limiting, and error recovery internally.
Example Implementation
class KaggleAdapter: ... async def search_competitions( ... self, categories: list[str], **kwargs ... ) -> AsyncIterator[Competition]: ... async for comp in self._api.list_competitions(): ... yield Competition.model_validate(comp)
Source code in agent_k/interfaces.py
20 21 22 23 24 25 26 27 28 29 30 31 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 | |
platform_name
abstractmethod
property
platform_name: str
Unique identifier for the platform.
authenticate
abstractmethod
async
authenticate() -> bool
Authenticate with the platform.
Returns:
| Type | Description |
|---|---|
bool
|
True if authentication successful. |
Raises:
| Type | Description |
|---|---|
AuthenticationError
|
If authentication fails. |
Source code in agent_k/interfaces.py
43 44 45 46 47 48 49 50 51 52 53 | |
search_competitions
abstractmethod
search_competitions(
categories: list[str] | None = None,
keywords: list[str] | None = None,
min_prize: int | None = None,
active_only: bool = True,
) -> AsyncIterator[Competition]
Search for competitions matching criteria.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
categories
|
list[str] | None
|
Filter by competition categories. |
None
|
keywords
|
list[str] | None
|
Keywords to search in title/description. |
None
|
min_prize
|
int | None
|
Minimum prize pool filter. |
None
|
active_only
|
bool
|
Only return active competitions. |
True
|
Yields:
| Type | Description |
|---|---|
AsyncIterator[Competition]
|
Competition entities matching criteria. |
Source code in agent_k/interfaces.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
get_competition
abstractmethod
async
get_competition(competition_id: str) -> Competition
Get detailed competition information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
competition_id
|
str
|
Unique competition identifier. |
required |
Returns:
| Type | Description |
|---|---|
Competition
|
Full Competition entity. |
Raises:
| Type | Description |
|---|---|
CompetitionNotFoundError
|
If competition doesn't exist. |
Source code in agent_k/interfaces.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
get_leaderboard
abstractmethod
async
get_leaderboard(
competition_id: str, *, limit: int = 100
) -> list[LeaderboardEntry]
Get competition leaderboard.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
competition_id
|
str
|
Target competition. |
required |
limit
|
int
|
Maximum entries to return. |
100
|
Returns:
| Type | Description |
|---|---|
list[LeaderboardEntry]
|
List of leaderboard entries sorted by rank. |
Source code in agent_k/interfaces.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
submit
abstractmethod
async
submit(
competition_id: str, file_path: str, message: str = ""
) -> Submission
Submit solution to competition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
competition_id
|
str
|
Target competition. |
required |
file_path
|
str
|
Path to submission file. |
required |
message
|
str
|
Optional submission message. |
''
|
Returns:
| Type | Description |
|---|---|
Submission
|
Submission entity with initial status. |
Raises:
| Type | Description |
|---|---|
SubmissionError
|
If submission fails. |
DeadlinePassedError
|
If competition has ended. |
Source code in agent_k/interfaces.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
get_submission_status
abstractmethod
async
get_submission_status(
competition_id: str, submission_id: str
) -> Submission
Get status of a submission.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
competition_id
|
str
|
Competition containing submission. |
required |
submission_id
|
str
|
Submission to check. |
required |
Returns:
| Type | Description |
|---|---|
Submission
|
Updated Submission entity. |
Source code in agent_k/interfaces.py
124 125 126 127 128 129 130 131 132 133 134 135 | |
download_data
abstractmethod
async
download_data(
competition_id: str, destination: str
) -> list[str]
Download competition data files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
competition_id
|
str
|
Target competition. |
required |
destination
|
str
|
Directory to download files to. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of downloaded file paths. |
Source code in agent_k/interfaces.py
137 138 139 140 141 142 143 144 145 146 147 148 | |
Core domain models for AGENT-K.
(c) Mike Casale 2026. Licensed under the MIT License.
CompetitionType
Bases: StrEnum
Type of Kaggle competition.
Source code in agent_k/models.py
33 34 35 36 37 38 39 40 | |
SubjectDomain
Bases: StrEnum
Subject domains for competition classification.
Source code in agent_k/models.py
43 44 45 46 47 48 49 50 51 52 53 54 | |
EvaluationMetric
Bases: StrEnum
Standard evaluation metrics for competitions.
Source code in agent_k/models.py
57 58 59 60 61 62 63 64 65 66 67 68 69 | |
Competition
Bases: BaseModel
Kaggle competition entity.
Represents a competition with all metadata required for evaluation and participation decisions.
Source code in agent_k/models.py
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 | |
is_active
property
is_active: bool
Whether competition is still accepting submissions.
days_remaining
property
days_remaining: int
Days until deadline (negative if passed).
validate_deadline_timezone
classmethod
validate_deadline_timezone(v: datetime) -> datetime
Ensure deadline has timezone information.
Source code in agent_k/models.py
106 107 108 109 110 111 112 | |
LeaderboardEntry
Bases: BaseModel
Entry in competition leaderboard.
Source code in agent_k/models.py
128 129 130 131 132 133 134 135 136 137 | |
Submission
Bases: BaseModel
Competition submission entity.
Source code in agent_k/models.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
MissionCriteria
Bases: BaseModel
Criteria constraining mission execution.
Source code in agent_k/models.py
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 | |
validate_domains_disjoint
validate_domains_disjoint() -> Self
Ensure target and exclude domains don't overlap.
Source code in agent_k/models.py
203 204 205 206 207 208 209 210 211 212 213 | |
Shared lightweight domain types used by API and worker modules.
(c) Mike Casale 2026. Licensed under the MIT License.
Exception hierarchy for AGENT-K system.
(c) Mike Casale 2026. Licensed under the MIT License.
AgentKError
Bases: Exception
Base exception for all AGENT-K errors.
All exceptions in the system inherit from this class, enabling catch-all handling at application boundaries.
Source code in agent_k/exceptions.py
43 44 45 46 47 48 49 50 51 52 53 54 55 | |
AgentError
Bases: AgentKError
Base exception for agent-related errors.
Source code in agent_k/exceptions.py
58 59 | |
AgentExecutionError
Bases: AgentError
Raised when agent execution fails.
Source code in agent_k/exceptions.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
ToolExecutionError
Bases: AgentError
Raised when a tool execution fails.
Source code in agent_k/exceptions.py
82 83 84 85 86 87 88 89 90 91 | |
OutputValidationError
Bases: AgentError
Raised when agent output fails validation.
Source code in agent_k/exceptions.py
94 95 96 97 98 99 100 101 102 103 | |
AdapterError
Bases: AgentKError
Base exception for adapter-related errors.
Source code in agent_k/exceptions.py
106 107 | |
PlatformConnectionError
Bases: AdapterError
Raised when connection to platform fails.
Source code in agent_k/exceptions.py
110 111 112 113 114 115 116 117 | |
AuthenticationError
Bases: AdapterError
Raised when platform authentication fails.
Source code in agent_k/exceptions.py
120 121 122 123 124 125 126 127 | |
RateLimitError
Bases: AdapterError
Raised when platform rate limit is exceeded.
Source code in agent_k/exceptions.py
130 131 132 133 134 135 136 137 138 | |
CompetitionError
Bases: AgentKError
Base exception for competition-related errors.
Source code in agent_k/exceptions.py
141 142 | |
CompetitionNotFoundError
Bases: CompetitionError
Raised when competition does not exist.
Source code in agent_k/exceptions.py
145 146 147 148 149 150 151 152 153 154 | |
CompetitionRulesNotAcceptedError
Bases: CompetitionError
Raised when competition rules have not been accepted.
Source code in agent_k/exceptions.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
SubmissionError
Bases: CompetitionError
Raised when submission fails.
Source code in agent_k/exceptions.py
174 175 176 177 178 179 180 181 182 183 184 185 | |
DeadlinePassedError
Bases: CompetitionError
Raised when competition deadline has passed.
Source code in agent_k/exceptions.py
188 189 190 191 192 193 194 195 196 197 198 | |
EvolutionError
Bases: AgentKError
Base exception for evolution-related errors.
Source code in agent_k/exceptions.py
201 202 | |
ConvergenceError
Bases: EvolutionError
Raised when evolution fails to converge within limits.
Source code in agent_k/exceptions.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
PopulationExtinctError
Bases: EvolutionError
Raised when all population members fail fitness evaluation.
Source code in agent_k/exceptions.py
222 223 224 225 226 227 228 229 230 231 232 | |
FitnessEvaluationError
Bases: EvolutionError
Raised when fitness evaluation fails.
Source code in agent_k/exceptions.py
235 236 237 238 239 240 241 242 243 244 245 246 | |
MemoryError
Bases: AgentKError
Base exception for memory-related errors.
Source code in agent_k/exceptions.py
249 250 | |
CheckpointError
Bases: MemoryError
Raised when checkpoint operations fail.
Source code in agent_k/exceptions.py
253 254 255 256 257 258 259 260 261 262 | |
MemoryCapacityError
Bases: MemoryError
Raised when memory capacity is exceeded.
Source code in agent_k/exceptions.py
265 266 267 268 269 270 271 272 273 274 | |
GraphError
Bases: AgentKError
Base exception for graph-related errors.
Source code in agent_k/exceptions.py
277 278 | |
StateTransitionError
Bases: GraphError
Raised when state transition is invalid.
Source code in agent_k/exceptions.py
281 282 283 284 285 286 287 288 289 290 291 | |
PhaseTimeoutError
Bases: GraphError
Raised when a phase exceeds its timeout.
Source code in agent_k/exceptions.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
classify_error
classify_error(
exc: Exception,
) -> tuple[ErrorCategory, RecoveryStrategy]
Classify errors into recovery categories and strategies.
Source code in agent_k/exceptions.py
311 312 313 314 315 316 317 318 319 320 321 | |