refactor: use a single agent model path
This commit is contained in:
@@ -1 +1 @@
|
||||
"""Model gateway and independently evolvable Work Agent runtime."""
|
||||
"""Model gateway and independently evolvable K1412 Agent runtime."""
|
||||
|
||||
@@ -10,7 +10,7 @@ from typing import Annotated, Any
|
||||
|
||||
import httpx
|
||||
import uvicorn
|
||||
from fastapi import FastAPI, Header, HTTPException, status
|
||||
from fastapi import FastAPI, Header, HTTPException
|
||||
from fastapi.responses import JSONResponse, StreamingResponse
|
||||
|
||||
from agent_platform.auth import UserIdentity, decode_openwebui_identity, verify_service_bearer
|
||||
@@ -198,16 +198,6 @@ def create_app(
|
||||
return await forward_direct()
|
||||
|
||||
stable_chat_id = (chat_id or message_id or f"ephemeral-{uuid.uuid4().hex}").strip()
|
||||
selected_mode = await app.state.store.select_mode(identity.user_id, chat_id or "", spec.mode)
|
||||
if selected_mode == "work" and spec.mode == "chat":
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_409_CONFLICT,
|
||||
detail="This conversation has been upgraded to Work and cannot return to Chat.",
|
||||
)
|
||||
|
||||
if spec.mode == "chat":
|
||||
return await forward_direct()
|
||||
|
||||
messages = [message.model_dump(exclude_none=True) for message in body.messages]
|
||||
if not body.stream:
|
||||
|
||||
@@ -224,7 +214,7 @@ def create_app(
|
||||
)
|
||||
return _completion(body.model, answer)
|
||||
|
||||
async def work_stream() -> AsyncIterator[bytes]:
|
||||
async def agent_stream() -> AsyncIterator[bytes]:
|
||||
queue: asyncio.Queue[tuple[str, Any]] = asyncio.Queue()
|
||||
|
||||
async def publish(event_type: str, payload: dict[str, Any]) -> None:
|
||||
@@ -255,7 +245,7 @@ def create_app(
|
||||
if kind == "done":
|
||||
break
|
||||
if kind == "error":
|
||||
yield _sse_chunk(body.model, f"\n\nWork 运行失败:{value}")
|
||||
yield _sse_chunk(body.model, f"\n\nAgent 运行失败:{value}")
|
||||
continue
|
||||
if kind == "answer":
|
||||
text = str(value)
|
||||
@@ -271,7 +261,7 @@ def create_app(
|
||||
await asyncio.gather(task, return_exceptions=True)
|
||||
|
||||
return StreamingResponse(
|
||||
work_stream(),
|
||||
agent_stream(),
|
||||
media_type="text/event-stream",
|
||||
headers={"Cache-Control": "no-cache", "X-Accel-Buffering": "no"},
|
||||
)
|
||||
|
||||
@@ -28,7 +28,7 @@ from agent_platform.store import RuntimeStore
|
||||
EventCallback = Callable[[str, dict[str, Any]], Awaitable[None]]
|
||||
|
||||
WORK_SYSTEM_PROMPT = """\
|
||||
You are Work, an autonomous coding Agent operating in one isolated user workspace at /workspace.
|
||||
You are K1412 Agent, an autonomous coding Agent operating in one isolated user workspace at /workspace.
|
||||
|
||||
Own the outcome: inspect the workspace, form a plan for non-trivial work, make scoped changes, run
|
||||
relevant verification, and report concrete results. Use tools instead of inventing file contents or
|
||||
@@ -514,8 +514,8 @@ class AgentLoop:
|
||||
await recorder.emit(
|
||||
"run.created",
|
||||
{
|
||||
"model_tier": spec.strength,
|
||||
"strategy_version": "work-loop-v2",
|
||||
"model_id": spec.public_id,
|
||||
"strategy_version": "agent-loop-v3",
|
||||
"scheduler_version": "safe-parallel-v1",
|
||||
"context_policy": "recent-visible-v1",
|
||||
},
|
||||
|
||||
@@ -200,14 +200,14 @@ TOOL_METADATA: dict[str, ToolMetadata] = {
|
||||
),
|
||||
"remember": ToolMetadata(
|
||||
"remember",
|
||||
"Store a durable user preference or fact that will help future Work tasks.",
|
||||
"Store a durable user preference or fact that will help future Agent tasks.",
|
||||
object_schema({"content": {"type": "string"}}, ["content"]),
|
||||
False,
|
||||
False,
|
||||
),
|
||||
"recall_memory": ToolMetadata(
|
||||
"recall_memory",
|
||||
"Search durable Work memory for this user.",
|
||||
"Search durable Agent memory for this user.",
|
||||
object_schema(
|
||||
{
|
||||
"query": {"type": "string", "default": ""},
|
||||
@@ -219,7 +219,7 @@ TOOL_METADATA: dict[str, ToolMetadata] = {
|
||||
),
|
||||
"forget_memory": ToolMetadata(
|
||||
"forget_memory",
|
||||
"Delete one durable Work memory by id.",
|
||||
"Delete one durable Agent memory by id.",
|
||||
object_schema({"memory_id": {"type": "string"}}, ["memory_id"]),
|
||||
False,
|
||||
False,
|
||||
|
||||
Reference in New Issue
Block a user