API Reference¶
Auto-generated from source docstrings via mkdocstrings. The shared
framework lives in semos-agentura-core; each agent is a thin BaseAgentService subclass.
Core framework (semos-agentura-core)¶
BaseAgentService¶
Abstract base every agent implements. Declares the tools and skills an agent exposes and serves them over both MCP and A2A.
Bases: ABC
Abstract base for all agent services.
Subclass this and implement the abstract properties/methods. The transport layer reads these to wire up MCP + A2A automatically.
Source code in packages/semos-agentura-core/src/semos/agentura/core/base.py
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 | |
agent_description
abstractmethod
property
¶
Short description of what this agent does.
agent_name
abstractmethod
property
¶
Human-readable agent name (e.g. 'Email Agent').
agent_system_prompt
property
¶
Agent-specific system prompt, appended to LLMExecutor's base prompt.
Default: current date/time. Override in subclasses: - Extend: return super().agent_system_prompt + "\n\nExtra instructions.". - Replace: return "Custom prompt." (omits date/time).
execute_skill(skill_id, message, *, task_id=None)
abstractmethod
async
¶
Execute an A2A skill by ID with the given message.
file_url(filename)
¶
Return the download URL for a file in the output directory.
get_skills()
abstractmethod
¶
get_tools()
abstractmethod
¶
resolve_file(source, default_ext='.bin', filename='')
¶
Resolve a source string to a local file Path.
Detects the format first, then resolves: 1. data URI (data:mime;base64,...) -> decode and write to temp file 2. raw base64 -> decode and write to temp file 3. HTTP(S) URL -> fetch and write to temp file 4. file path -> return as-is if it exists
If filename is provided, the temp file preserves that name (important for downstream tools that infer type from name).
Source code in packages/semos-agentura-core/src/semos/agentura/core/base.py
resolve_file_attachment(source, default_ext='.bin')
¶
Resolve a FileAttachment dict or plain string to a local Path.
Source code in packages/semos-agentura-core/src/semos/agentura/core/base.py
LLMExecutor¶
The universal agentic loop: takes a message plus tool definitions, drives the model/tool cycle, and
emits an ExecutorResult.
Multi-step LLM tool-calling loop.
Supports Anthropic (native + Azure AI Foundry) and OpenAI-compatible APIs. Injects 5 synthetic tools for task lifecycle control.
Source code in packages/semos-agentura-core/src/semos/agentura/core/llm_executor.py
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 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 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 674 675 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 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 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 769 770 771 772 773 774 775 776 777 778 779 780 | |
run(message, files=None, history=None)
async
¶
Run the agentic loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
User/requester message text. |
required |
files
|
list[dict] | None
|
FileAttachment dicts [{name, content}] for inline files. |
None
|
history
|
list[dict] | None
|
Prior conversation messages for continuation. |
None
|
Returns:
| Type | Description |
|---|---|
ExecutorResult
|
ExecutorResult with text, files, status, and history. |
Source code in packages/semos-agentura-core/src/semos/agentura/core/llm_executor.py
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 | |
Tools¶
AgentTool / the agent_tool decorator define callable tools; ToolResult is the normalized,
multi-modal return type (text + data + files).
Bases: BaseTool
Tool with MCP annotations, file param auto-detection, and Pydantic validation.
Subclass this for each tool, or use the @agent_tool decorator for simple cases.
Example (subclass): class DigestInput(BaseModel): source: FileAttachment | str = Field(description="Document to digest")
class DigestDocumentTool(AgentTool):
name: str = "digest_document"
description: str = "Digest a document into Markdown."
args_schema: type[BaseModel] = DigestInput
read_only: bool = True
async def _arun(self, **kwargs) -> str:
...
Example (decorator): @agent_tool(read_only=True) async def get_examples(category: str = "") -> str: """List available examples.""" ...
Source code in packages/semos-agentura-core/src/semos/agentura/core/base.py
resolved_file_params
property
¶
File parameter names, auto-detected if not explicitly set.
bind_service(service)
¶
Bind this tool to a service instance. Returns self for chaining.
get_input_schema()
¶
Return JSON Schema for this tool's input parameters.
Uses parameters_override if set, otherwise generates from args_schema.
Source code in packages/semos-agentura-core/src/semos/agentura/core/base.py
Decorator to create an AgentTool from an async function.
Usage
@agent_tool(read_only=True) async def search_emails(query: str, limit: int = 50) -> str: """Search emails matching a query.""" ...
The tool's name defaults to the function name. Description comes from the docstring. args_schema is auto-generated from the function signature.
Source code in packages/semos-agentura-core/src/semos/agentura/core/base.py
Structured result from a tool function.
Tool functions can return any Python type - the MCP wrapper normalizes it automatically: str -> ToolResult(text=...) dict/list -> ToolResult(data=...) Path -> ToolResult(files=[...]) NamedFile -> ToolResult(files=[...]) ToolResult -> pass through
Use ToolResult directly only when returning multiple modalities (e.g., text + files, or data + files).
Source code in packages/semos-agentura-core/src/semos/agentura/core/base.py
SkillDef¶
A2A skill definition advertised on the agent card.
Definition of a skill that the agent exposes via A2A.
Source code in packages/semos-agentura-core/src/semos/agentura/core/base.py
AgenturaClient¶
Reference client for both MCP tools and A2A task delegation across agents.
Headless MCP client with symmetric file middleware.
LLM only sees symbolic filenames. Middleware resolves file content on input and fetches/registers produced files on output.
Source code in packages/semos-agentura-core/src/semos/agentura/core/client.py
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 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 | |
a2a_agents
property
¶
Discovered A2A agents.
tools
property
¶
All tools from all connected agents.
__init__(agents, download_dir=None)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agents
|
dict[str, str]
|
Mapping of agent name to base URL. e.g. {"document": "http://localhost:8002"} |
required |
download_dir
|
Path | None
|
Directory for downloaded files. Defaults to a temp directory. |
None
|
Source code in packages/semos-agentura-core/src/semos/agentura/core/client.py
ask_agent(name, message, files=None, data=None, task_id=None)
async
¶
Delegate a task to an agent via A2A.
The LLM calls this with symbolic filenames. Middleware resolves them to inline base64 content. Produced files are fetched and registered back in the registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Agent name (must match key in agents dict). |
required |
message
|
str
|
Natural language request. |
required |
files
|
list[str] | None
|
Symbolic filenames from the registry. |
None
|
data
|
dict | None
|
Optional structured data dict. |
None
|
task_id
|
str | None
|
Continue an existing task (multi-turn). |
None
|
Returns:
| Type | Description |
|---|---|
ClientA2AResult
|
ClientA2AResult with LLM-safe text (no URLs), |
ClientA2AResult
|
registered files, task_id, and status. |
Source code in packages/semos-agentura-core/src/semos/agentura/core/client.py
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 | |
call_tool(name, args)
async
¶
Call a tool with file middleware.
- Pre-middleware: resolve symbolic filenames to content
- MCP call_tool
- Post-middleware: fetch produced files, register, strip URLs
Source code in packages/semos-agentura-core/src/semos/agentura/core/client.py
close()
async
¶
connect()
async
¶
Connect to all agents via MCP SSE and discover A2A.
Source code in packages/semos-agentura-core/src/semos/agentura/core/client.py
upload(path, name=None)
¶
Register a local file in the file registry.
Returns the symbolic filename the LLM should use.
Source code in packages/semos-agentura-core/src/semos/agentura/core/client.py
upload_bytes(blob, filename, mime='application/octet-stream')
¶
Register raw bytes in the file registry.
Source code in packages/semos-agentura-core/src/semos/agentura/core/client.py
MCPHub¶
Connects to external MCP servers and exposes their tools to an agent.
Manages persistent SSE connections to multiple MCP agents.
Supports a two-phase lifecycle: 1. discover() - connect, list tools, disconnect 2. ensure_connected() - reconnect lazily on first tool call
Source code in packages/semos-agentura-core/src/semos/agentura/core/mcp_client.py
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 | |
agent_for_tool(tool_name)
¶
Look up which agent owns a tool.
all_tools()
¶
Return all tools from all connected agents.
call_tool(tool_name, arguments)
async
¶
Route a tool call to the correct agent.
Source code in packages/semos-agentura-core/src/semos/agentura/core/mcp_client.py
connect_all()
async
¶
Open SSE connections, initialize sessions, list tools.
Source code in packages/semos-agentura-core/src/semos/agentura/core/mcp_client.py
disconnect_all()
async
¶
Close all connections (keeps tool metadata).
Source code in packages/semos-agentura-core/src/semos/agentura/core/mcp_client.py
discover()
async
¶
Connect, list tools, disconnect. Returns tool metadata.
Tool metadata (names, schemas) is preserved after disconnect.
Source code in packages/semos-agentura-core/src/semos/agentura/core/mcp_client.py
ensure_connected()
async
¶
Reconnect if not currently connected.
Uses a lock to prevent parallel tool calls from triggering concurrent reconnections.
Source code in packages/semos-agentura-core/src/semos/agentura/core/mcp_client.py
tool_schema(tool_name)
¶
Get the Tool schema for a tool by name.
Source code in packages/semos-agentura-core/src/semos/agentura/core/mcp_client.py
create_app¶
Wires a BaseAgentService into a FastAPI app serving MCP and A2A endpoints.
Build a FastAPI app with MCP SSE + A2A + /health + /files.
Routes
GET /health -> health check
GET /mcp/sse -> MCP SSE stream
POST /mcp/messages/ -> MCP messages
GET /.well-known/agent-card.json -> A2A Agent Card
POST /a2a -> A2A JSON-RPC (when implemented)
GET /files/
Source code in packages/semos-agentura-core/src/semos/agentura/core/transport.py
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 | |
Agents¶
DocumentAgentService¶
Document digestion (OCR to Markdown) and composition (Markdown to documents).
Bases: BaseAgentService
Exposes document-agent's tools via MCP and skills via A2A.
Source code in packages/semos-agentura-document/src/semos/agentura/document/service.py
EmailAgentService¶
Unified email client over IMAP/SMTP and Outlook COM, with the @mailgent LLM agent.
Bases: BaseAgentService
Exposes email-agent's tools via MCP and skills via A2A.
Source code in packages/semos-agentura-email/src/semos/agentura/email/service.py
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 | |
run_sync(fn)
async
¶
Run fn(backend) on the appropriate thread.
COM: dedicated worker thread (apartment-threaded). IMAP/Graph: asyncio.to_thread (thread-safe). Pre-injected mock: used directly (tests).
Source code in packages/semos-agentura-email/src/semos/agentura/email/service.py
FilesystemAgentService¶
Multi-root virtual filesystem (local, WebDAV, SharePoint, archives) exposed as MCP/A2A tools.
Bases: BaseAgentService
Source code in packages/semos-agentura-files/src/semos/agentura/files/service.py
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 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 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 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 674 675 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 712 713 714 | |