Control-plane reference
Expose authenticated mission, worker, artifact, and migration APIs.
(c) Mike Casale 2026. Licensed under the MIT License.
ErrorDetail
Bases: _WireModel
Machine-readable API failure.
Source code in agent_k/api.py
77 78 79 80 81 82 83 84 | |
ErrorResponse
Bases: _WireModel
Stable error envelope returned by every JSON endpoint.
Source code in agent_k/api.py
87 88 89 90 91 | |
ApiError
Bases: Exception
HTTP-safe application error with a stable wire code.
Source code in agent_k/api.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
UserIdentity
Bases: _WireModel
Verified identity forwarded by the Auth.js frontend.
Source code in agent_k/api.py
114 115 116 117 118 | |
WorkerIdentity
Bases: _WireModel
Verified internal worker identity.
Source code in agent_k/api.py
121 122 123 124 | |
GatewayClaims
Bases: _WireModel
Signed short-lived frontend identity claims.
Source code in agent_k/api.py
127 128 129 130 131 132 133 134 135 | |
GatewayVerifier
dataclass
Verify HMAC-signed frontend identity tokens with key rotation.
Source code in agent_k/api.py
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 | |
verify
verify(token: str) -> UserIdentity
Verify one compact HS256 token and return its user identity.
Source code in agent_k/api.py
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 | |
WorkerVerifier
dataclass
Verify rotatable opaque internal worker bearer tokens.
Source code in agent_k/api.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
verify
verify(token: str, worker_id: str) -> WorkerIdentity
Return the worker identity when a configured token matches.
Source code in agent_k/api.py
194 195 196 197 198 199 200 201 202 | |
MissionStartRequest
Bases: _WireModel
Create a durable mission job.
Source code in agent_k/api.py
205 206 207 208 209 210 211 212 213 | |
MissionStartResponse
Bases: _WireModel
Identity and initial status of a newly queued mission.
Source code in agent_k/api.py
216 217 218 219 220 | |
MissionStatusResponse
Bases: _WireModel
Current durable mission status.
Source code in agent_k/api.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
MissionControlResponse
Bases: _WireModel
Accepted user control request.
Source code in agent_k/api.py
241 242 243 244 245 246 | |
CompetitionSearchRequest
Bases: _WireModel
Search filters for the real competition platform.
Source code in agent_k/api.py
249 250 251 252 253 254 255 256 | |
CompetitionFetchRequest
Bases: _WireModel
Fetch one competition by its platform URL.
Source code in agent_k/api.py
259 260 261 262 | |
ControlState
Bases: _WireModel
Control action visible to a leased worker.
Source code in agent_k/api.py
265 266 267 268 269 270 | |
JobCommand
Bases: _WireModel
Mission command assigned to a worker.
Source code in agent_k/api.py
273 274 275 276 277 278 279 | |
JobWorkspace
Bases: _WireModel
Artifact namespace reserved for one job attempt.
Source code in agent_k/api.py
282 283 284 285 | |
ClaimedJob
Bases: _WireModel
Fenced lease and mission command returned by a claim.
Source code in agent_k/api.py
288 289 290 291 292 293 294 295 296 297 298 299 | |
ClaimJobsRequest
Bases: _WireModel
Worker request for available jobs.
Source code in agent_k/api.py
302 303 304 305 306 307 308 | |
ClaimJobsResponse
Bases: _WireModel
Atomically claimed jobs and server clock.
Source code in agent_k/api.py
311 312 313 314 315 | |
HeartbeatRequest
Bases: _WireModel
Renew a fenced job lease and report progress.
Source code in agent_k/api.py
318 319 320 321 322 323 324 325 | |
HeartbeatResponse
Bases: _WireModel
Renewed lease and current control action.
Source code in agent_k/api.py
328 329 330 331 332 333 334 335 | |
AppendEventsRequest
Bases: _WireModel
Append one contiguous ordered batch of mission events.
Source code in agent_k/api.py
338 339 340 341 342 343 | |
AppendEventsResponse
Bases: _WireModel
Event append acknowledgement.
Source code in agent_k/api.py
346 347 348 349 350 351 | |
SnapshotPayload
Bases: _WireModel
Versioned mission snapshot supplied by a worker.
Source code in agent_k/api.py
354 355 356 357 358 359 360 361 | |
SaveSnapshotRequest
Bases: _WireModel
Save an idempotent mission snapshot.
Source code in agent_k/api.py
364 365 366 367 368 369 | |
SaveSnapshotResponse
Bases: _WireModel
Stored snapshot identity.
Source code in agent_k/api.py
372 373 374 375 376 377 | |
ArtifactReference
Bases: _WireModel
Artifact attached to a terminal mission result.
Source code in agent_k/api.py
380 381 382 383 384 | |
MissionSnapshotResponse
Bases: _WireModel
Durable resume snapshot and its externally stored artifacts.
Source code in agent_k/api.py
387 388 389 390 391 392 393 394 395 396 397 398 | |
MissionResultPayload
Bases: _WireModel
Successful worker result for a mission.
Source code in agent_k/api.py
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
CompleteJobRequest
Bases: _WireModel
Commit a terminal successful job result.
Source code in agent_k/api.py
419 420 421 422 423 424 425 426 427 | |
CompleteJobResponse
Bases: _WireModel
Committed successful job status.
Source code in agent_k/api.py
430 431 432 433 434 435 436 | |
WorkerFailure
Bases: _WireModel
Sanitized worker failure safe for persistence and operators.
Source code in agent_k/api.py
439 440 441 442 443 444 445 446 | |
FailJobRequest
Bases: _WireModel
Commit or retry a terminal worker failure.
Source code in agent_k/api.py
449 450 451 452 453 454 455 456 | |
FailJobResponse
Bases: _WireModel
Failure disposition selected by the runtime store.
Source code in agent_k/api.py
459 460 461 462 463 464 465 466 467 | |
WorkerControlResponse
Bases: ControlState
Current worker control state and server clock.
Source code in agent_k/api.py
470 471 472 473 | |
ArtifactUploadRequest
Bases: _WireModel
Request a constrained signed artifact upload URL.
Source code in agent_k/api.py
476 477 478 479 480 481 482 483 484 485 | |
ArtifactDownloadRequest
Bases: _WireModel
Request a constrained signed artifact download URL.
Source code in agent_k/api.py
488 489 490 491 492 | |
CompleteArtifactRequest
Bases: _WireModel
Finalize an uploaded artifact after server-side object verification.
Source code in agent_k/api.py
495 496 497 498 499 500 501 | |
CompleteArtifactResponse
Bases: _WireModel
Verified immutable artifact status.
Source code in agent_k/api.py
504 505 506 507 508 509 | |
SignedArtifactResponse
Bases: _WireModel
Short-lived signed object storage operation.
Source code in agent_k/api.py
512 513 514 515 516 517 518 519 | |
MigrationSource
Bases: _WireModel
Source metadata for one legacy persistence upload.
Source code in agent_k/api.py
522 523 524 525 526 527 528 | |
CreateMigrationRequest
Bases: _WireModel
Create a signed upload for a legacy state migration.
Source code in agent_k/api.py
531 532 533 534 535 536 537 | |
SignedOperation
Bases: _WireModel
Signed storage operation embedded in another response.
Source code in agent_k/api.py
540 541 542 543 544 545 546 547 | |
CreateMigrationResponse
Bases: _WireModel
Migration identity and its signed upload operation.
Source code in agent_k/api.py
550 551 552 553 554 555 | |
CompleteMigrationRequest
Bases: _WireModel
Confirm a completed legacy state upload.
Source code in agent_k/api.py
558 559 560 561 562 563 564 | |
MigrationStatusResponse
Bases: _WireModel
Current migration processing status.
Source code in agent_k/api.py
567 568 569 570 571 572 573 574 575 576 577 578 579 | |
ChatRequest
Bases: _WireModel
Vercel AI-style request forwarded by the authenticated frontend.
Source code in agent_k/api.py
582 583 584 585 586 587 | |
RuntimeStore
Bases: Protocol
Durable mission and worker operations required by the API.
Source code in agent_k/api.py
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | |
create_mission
async
create_mission(
*, owner_id: str, request: JsonObject
) -> JsonObject
Create and enqueue one owned mission.
Source code in agent_k/api.py
593 594 595 | |
get_mission
async
get_mission(mission_id: str) -> JsonObject | None
Return one mission without applying an ownership check.
Source code in agent_k/api.py
597 598 599 | |
require_owner
async
require_owner(mission_id: str, owner_id: str) -> JsonObject
Return a mission only when the principal owns it.
Source code in agent_k/api.py
601 602 603 | |
request_control
async
request_control(
mission_id: str,
owner_id: str,
action: MissionControlAction,
reason: str | None,
) -> JsonObject
Persist an owner-authorized mission control request.
Source code in agent_k/api.py
605 606 607 608 609 610 611 612 613 | |
list_events
async
list_events(
mission_id: str,
after_sequence: int,
limit: int = DEFAULT_EVENT_BATCH_SIZE,
) -> list[JsonObject]
Replay mission events after a durable global cursor.
Source code in agent_k/api.py
615 616 617 618 619 620 621 622 | |
list_best_results
async
list_best_results(
owner_id: str, limit: int
) -> list[JsonObject]
Return ranked results restricted to one owner.
Source code in agent_k/api.py
624 625 626 | |
claim_jobs
async
claim_jobs(request: JsonObject) -> JsonObject
Atomically claim available jobs for a worker.
Source code in agent_k/api.py
628 629 630 | |
heartbeat
async
heartbeat(job_id: str, request: JsonObject) -> JsonObject
Renew a fenced job lease.
Source code in agent_k/api.py
632 633 634 | |
append_events
async
append_events(
job_id: str, request: JsonObject
) -> JsonObject
Append an ordered worker event batch.
Source code in agent_k/api.py
636 637 638 | |
save_snapshot
async
save_snapshot(
job_id: str, request: JsonObject
) -> JsonObject
Persist an idempotent mission snapshot.
Source code in agent_k/api.py
640 641 642 | |
get_snapshot
async
get_snapshot(
job_id: str,
snapshot_id: str,
worker_id: str,
lease_id: str,
) -> JsonObject | None
Load a snapshot through a current fenced lease.
Source code in agent_k/api.py
644 645 646 647 648 649 650 651 652 | |
complete_job
async
complete_job(
job_id: str, request: JsonObject
) -> JsonObject
Commit a successful fenced job.
Source code in agent_k/api.py
654 655 656 | |
fail_job
async
fail_job(job_id: str, request: JsonObject) -> JsonObject
Commit or retry a failed fenced job.
Source code in agent_k/api.py
658 659 660 | |
get_control
async
get_control(
job_id: str, worker_id: str, lease_id: str
) -> JsonObject
Return control state through a current fenced lease.
Source code in agent_k/api.py
662 663 664 665 666 667 668 669 | |
get_migration
async
get_migration(migration_id: str) -> JsonObject | None
Return one durable migration record.
Source code in agent_k/api.py
671 672 673 | |
SignedArtifactStore
Bases: Protocol
Sign constrained S3 artifact transfers without proxying file bytes.
Source code in agent_k/api.py
676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 | |
sign_upload
async
sign_upload(job_id: str, request: JsonObject) -> JsonObject
Reserve and sign a checksum-bound artifact upload.
Source code in agent_k/api.py
679 680 681 | |
sign_download
async
sign_download(
job_id: str, artifact_id: str, request: JsonObject
) -> JsonObject
Sign a fenced artifact download.
Source code in agent_k/api.py
683 684 685 686 687 688 689 690 | |
complete_upload
async
complete_upload(
job_id: str, artifact_id: str, request: JsonObject
) -> JsonObject
Verify and finalize one artifact upload.
Source code in agent_k/api.py
692 693 694 695 696 697 698 699 | |
create_migration
async
create_migration(request: JsonObject) -> JsonObject
Create a signed legacy-state upload.
Source code in agent_k/api.py
701 702 703 | |
complete_migration
async
complete_migration(
migration_id: str, request: JsonObject
) -> JsonObject
Verify and enqueue one legacy-state migration.
Source code in agent_k/api.py
705 706 707 708 709 710 711 | |
CompetitionGateway
Bases: Protocol
Real competition platform operations exposed to authenticated users.
Source code in agent_k/api.py
714 715 716 717 718 719 720 721 722 723 | |
search
async
search(request: JsonObject) -> list[JsonObject]
Search real competitions with validated filters.
Source code in agent_k/api.py
717 718 719 | |
fetch
async
fetch(url: str) -> JsonObject
Fetch one exact competition by URL.
Source code in agent_k/api.py
721 722 723 | |
ApiRuntime
dataclass
Lifespan-owned API dependencies.
Source code in agent_k/api.py
726 727 728 729 730 731 732 733 734 | |
create_app
create_app(
runtime_factory: RuntimeFactory | None = None,
) -> FastAPI
Create the FastAPI application without import-time resource access.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
runtime_factory
|
RuntimeFactory | None
|
Lifespan context that owns stores and external clients. |
None
|
Returns:
| Type | Description |
|---|---|
FastAPI
|
A configured FastAPI application. |
Source code in agent_k/api.py
737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 | |
main
main() -> None
Run the production API entry point.
Source code in agent_k/api.py
1909 1910 1911 1912 1913 | |
Define durable mission events and browser-compatible SSE serialization.
(c) Mike Casale 2026. Licensed under the MIT License.
WorkerEvent
Bases: _WireModel
Event submitted by a leased worker.
Source code in agent_k/events.py
111 112 113 114 115 116 117 118 | |
AgentKEvent
Bases: WorkerEvent
Durable event associated with a mission.
Source code in agent_k/events.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
to_browser_event
to_browser_event() -> BrowserEvent
Return the stable event envelope consumed by the frontend.
Source code in agent_k/events.py
127 128 129 | |
to_sse
to_sse() -> str
Serialize the event as an ordered, resumable SSE frame.
Source code in agent_k/events.py
131 132 133 134 135 136 137 | |
BrowserEvent
Bases: _WireModel
Stable event envelope exposed to browser clients.
Source code in agent_k/events.py
140 141 142 143 144 145 | |
EventSink
Bases: Protocol
Append mission events to a durable ordered store.
Source code in agent_k/events.py
148 149 150 151 152 153 154 155 156 157 158 159 160 | |
append_event
async
append_event(
mission_id: str,
event_type: EventType,
data: EventData,
*,
timestamp: datetime,
) -> AgentKEvent
Append one event and return its assigned durable identity.
Source code in agent_k/events.py
151 152 153 154 155 156 157 158 159 160 | |
EventEmitter
dataclass
Emit camelCase mission events through a durable event sink.
Source code in agent_k/events.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 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 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | |
emit
async
emit(event_type: EventType, data: EventData) -> AgentKEvent
Append one event to the mission's ordered stream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
event_type
|
EventType
|
Stable browser-facing event name. |
required |
data
|
EventData
|
JSON-compatible camelCase event payload. |
required |
Returns:
| Type | Description |
|---|---|
AgentKEvent
|
The durable event with its assigned sequence and identifier. |
Source code in agent_k/events.py
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 | |
emit_phase_start
async
emit_phase_start(
phase: str, objectives: list[str]
) -> AgentKEvent
Emit a phase-start event.
Source code in agent_k/events.py
198 199 200 201 202 203 204 205 206 207 | |
emit_phase_complete
async
emit_phase_complete(
phase: str, success: bool, duration_ms: int
) -> AgentKEvent
Emit a phase-complete event.
Source code in agent_k/events.py
209 210 211 212 213 214 215 216 217 218 219 | |
emit_phase_error
async
emit_phase_error(
phase: str, error: str, recoverable: bool
) -> AgentKEvent
Emit a phase-error event.
Source code in agent_k/events.py
221 222 223 224 225 226 227 228 229 230 231 | |
emit_task_start
async
emit_task_start(
task_id: str, phase: str, name: str
) -> AgentKEvent
Emit a task-start event.
Source code in agent_k/events.py
233 234 235 236 237 238 239 240 241 242 243 | |
emit_task_progress
async
emit_task_progress(
task_id: str,
progress: float,
message: str | None = None,
) -> AgentKEvent
Emit a task-progress event.
Source code in agent_k/events.py
245 246 247 248 249 250 251 252 253 254 255 | |
emit_task_complete
async
emit_task_complete(
task_id: str,
success: bool,
result: EventData = None,
duration_ms: int = 0,
) -> AgentKEvent
Emit a task-complete event.
Source code in agent_k/events.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
emit_tool_start
async
emit_tool_start(
task_id: str,
tool_call_id: str,
tool_type: str,
operation: str,
params: dict[str, EventData] | None = None,
) -> AgentKEvent
Emit a tool-start event.
Source code in agent_k/events.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
emit_tool_thinking
async
emit_tool_thinking(
task_id: str, tool_call_id: str, chunk: str
) -> AgentKEvent
Emit a tool-thinking event.
Source code in agent_k/events.py
295 296 297 298 299 300 301 302 303 304 305 | |
emit_tool_result
async
emit_tool_result(
task_id: str,
tool_call_id: str,
result: EventData,
duration_ms: int,
) -> AgentKEvent
Emit a tool-result event.
Source code in agent_k/events.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | |
emit_tool_error
async
emit_tool_error(
task_id: str, tool_call_id: str, error: str
) -> AgentKEvent
Emit a tool-error event.
Source code in agent_k/events.py
325 326 327 328 329 330 331 332 333 334 335 | |
emit_generation_start
async
emit_generation_start(
generation: int,
population_size: int,
*,
model_family: ModelFamily | None = None,
model_size: ModelSize | None = None,
iteration: int | None = None,
total_iterations: int | None = None,
) -> AgentKEvent
Emit a generation-start event with optional runtime metadata.
Source code in agent_k/events.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
emit_generation_complete
async
emit_generation_complete(
generation: int,
best_fitness: float,
mean_fitness: float,
worst_fitness: float,
population_size: int,
mutations: dict[str, int],
*,
model_family: ModelFamily | None = None,
model_size: ModelSize | None = None,
iteration: int | None = None,
total_iterations: int | None = None,
) -> AgentKEvent
Emit a generation-complete event.
Source code in agent_k/events.py
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 | |
emit_submission_result
async
emit_submission_result(
submission_id: str,
generation: int,
cv_score: float,
public_score: float | None,
rank: int | None,
total_teams: int | None,
) -> AgentKEvent
Emit a submission-result event.
Source code in agent_k/events.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | |
emit_convergence_detected
async
emit_convergence_detected(
generation: int, reason: str
) -> AgentKEvent
Emit a convergence-detected event.
Source code in agent_k/events.py
422 423 424 425 426 427 428 429 430 431 | |
emit_memory_store
async
emit_memory_store(
key: str, scope: str, category: str
) -> AgentKEvent
Emit a memory-store event.
Source code in agent_k/events.py
433 434 435 436 437 438 439 440 441 442 443 | |
emit_memory_retrieve
async
emit_memory_retrieve(key: str, found: bool) -> AgentKEvent
Emit a memory-retrieve event.
Source code in agent_k/events.py
445 446 447 448 449 450 451 | |
emit_checkpoint_created
async
emit_checkpoint_created(
name: str, phase: str
) -> AgentKEvent
Emit a checkpoint-created event.
Source code in agent_k/events.py
453 454 455 456 457 458 459 460 461 462 | |
emit_error
async
emit_error(
error_id: str,
category: str,
error_type: str,
message: str,
context: str,
recovery_strategy: str,
) -> AgentKEvent
Emit an error-occurred event.
Source code in agent_k/events.py
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | |
emit_recovery_attempt
async
emit_recovery_attempt(
error_id: str, strategy: str, attempt: int
) -> AgentKEvent
Emit a recovery-attempt event.
Source code in agent_k/events.py
489 490 491 492 493 494 495 496 497 498 499 | |
emit_recovery_complete
async
emit_recovery_complete(
error_id: str,
success: bool,
resolution: str | None = None,
) -> AgentKEvent
Emit a recovery-complete event.
Source code in agent_k/events.py
501 502 503 504 505 506 507 508 509 510 511 | |
emit_mission_complete
async
emit_mission_complete(
*,
success: bool,
final_rank: int | None,
final_score: float | None,
error_message: str | None = None,
total_submissions: int,
evolution_generations: int,
evolution_iterations: int | None = None,
duration_ms: int,
phases_completed: list[str],
evolution_failure_summary: dict[str, int] | None = None,
) -> AgentKEvent
Emit the canonical camelCase mission-complete event.
Source code in agent_k/events.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | |
parse_last_event_id
parse_last_event_id(value: str | None) -> int
Parse an SSE Last-Event-ID value into the last delivered sequence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str | None
|
Header value supplied by the browser, or |
required |
Returns:
| Type | Description |
|---|---|
int
|
The non-negative last delivered event sequence. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the value is not a non-negative integer. |
Source code in agent_k/events.py
548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | |
Classify mission intent without import-time model or network access.
(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 | |
MissionCriteriaInput
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 | |
MissionIntentResult
Bases: BaseModel
Deterministic classification result for one user message.
Source code in agent_k/intent.py
79 80 81 82 83 84 85 | |
MissionIntentParser
dataclass
Extract mission intent and criteria using deterministic language rules.
Source code in agent_k/intent.py
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 | |
parse
parse(message: str) -> MissionIntentResult
Classify one message and extract supported mission criteria.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
User-authored text from the latest chat message. |
required |
Returns:
| Type | Description |
|---|---|
MissionIntentResult
|
A classification and validated criteria for mission requests. |
Source code in agent_k/intent.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
parse_mission_intent
parse_mission_intent(
messages: list[dict[str, Any]],
*,
parser: MissionIntentParser | None = None,
) -> MissionIntentResult
Parse the latest user text from a frontend chat message list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages
|
list[dict[str, Any]]
|
Vercel AI-style messages with text parts. |
required |
parser
|
MissionIntentParser | None
|
Optional deterministic parser configuration. |
None
|
Returns:
| Type | Description |
|---|---|
MissionIntentResult
|
A non-mission result when no usable user text is present. |
Source code in agent_k/intent.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
extract_latest_user_message
extract_latest_user_message(
messages: list[dict[str, Any]],
) -> str | None
Return text from the latest user message without accepting other roles.
Source code in agent_k/intent.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
Runtime settings, loaded explicitly by API and worker entry points.
(c) Mike Casale 2026. Licensed under the MIT License.
Settings
Bases: BaseSettings
Validated configuration for a mission process.
Environment names use the AGENT_K_ prefix. Provider and Kaggle credentials
stay in the worker environment; none are forwarded to candidate containers.
Source code in agent_k/config.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 | |
load_settings
load_settings() -> Settings
Read current environment values without an import-time singleton.
Source code in agent_k/config.py
57 58 59 | |
Logfire instrumentation configured at application startup.
(c) Mike Casale 2026. Licensed under the MIT License.
configure_observability
configure_observability(
*, service_name: str, environment: str
) -> None
Configure telemetry once in each API, worker, or mission process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service_name
|
str
|
Deployment role included in telemetry resource attributes. |
required |
environment
|
str
|
Runtime environment included in telemetry resource attributes. |
required |
Agent instrumentation records timing and usage without prompts, completions, tool content, or binary payloads. A configured Logfire token enables remote export.
Source code in agent_k/observability.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |