refactor: break up create_gitea_issue_via_mcp into helpers (#647)

Co-authored-by: Kimi Agent <kimi@timmy.local>
Co-committed-by: Kimi Agent <kimi@timmy.local>
This commit is contained in:
2026-03-20 17:29:55 -04:00
committed by Timmy Time
parent faad0726a2
commit 001358c64f
2 changed files with 57 additions and 9 deletions

View File

@@ -205,9 +205,9 @@ def _bridge_to_work_order(title: str, body: str, category: str) -> None:
async def _ensure_issue_session():
"""Lazily create and connect the module-level MCP issue session.
"""Get or create the cached MCP session, connecting if needed.
Returns the connected ``MCPTools`` instance or raises on failure.
Returns the connected ``MCPTools`` instance.
"""
from agno.tools.mcp import MCPTools
@@ -226,18 +226,18 @@ async def _ensure_issue_session():
return _issue_session
def _build_issue_args(title: str, body: str) -> dict:
"""Build the ``issue_write`` tool arguments dict.
Appends the auto-filing signature and parses owner/repo from settings.
"""
def _build_issue_body(body: str) -> str:
"""Append the auto-filing signature to the issue body."""
full_body = body
if full_body:
full_body += "\n\n"
full_body += "---\n*Auto-filed by Timmy's thinking engine*"
return full_body
def _build_issue_args(title: str, full_body: str) -> dict:
"""Build MCP tool arguments for ``issue_write`` with method=create."""
owner, repo = settings.gitea_repo.split("/", 1)
return {
"method": "create",
"owner": owner,
@@ -272,7 +272,9 @@ async def create_gitea_issue_via_mcp(title: str, body: str = "", labels: str = "
try:
session = await _ensure_issue_session()
args = _build_issue_args(title, body)
full_body = _build_issue_body(body)
args = _build_issue_args(title, full_body)
result = await session.session.call_tool("issue_write", arguments=args)
_bridge_to_work_order(title, body, _category_from_labels(labels))