This commit is contained in:
Timothy Jaeryang Baek
2026-08-04 00:27:36 -05:00
Unverified
parent 368946e5a1
commit 6dba55b7ff
2 changed files with 6 additions and 8 deletions
+1 -5
View File
@@ -940,7 +940,7 @@ async def send_message(body: SendMessageRequest, request: Request):
"""
user_id = _get_user(request)
from cptr.utils.model_targets import AgentModelTarget, resolve_model_target
from cptr.utils.model_targets import resolve_model_target
target = await resolve_model_target(body.model_id, request.app.state)
@@ -950,8 +950,6 @@ async def send_message(body: SendMessageRequest, request: Request):
if not chat or chat.user_id != user_id:
raise HTTPException(404, "chat not found")
workspace = (chat.meta or {}).get("workspace") or None
if not workspace and isinstance(target, AgentModelTarget):
raise HTTPException(400, "Home chats require an API model")
# Sync params into chat meta
if chat.meta is None:
chat.meta = {}
@@ -961,8 +959,6 @@ async def send_message(body: SendMessageRequest, request: Request):
await Chat.update_meta(chat.id, chat.meta)
else:
workspace = body.workspace or None
if not workspace and isinstance(target, AgentModelTarget):
raise HTTPException(400, "Home chats require an API model")
title = body.content[:50].strip() or "New Chat"
meta = {
"params": body.params,
+5 -3
View File
@@ -10,6 +10,7 @@ import json
import logging
import re
import uuid
from pathlib import Path
from typing import Any
from cptr.events import EVENTS, publish_event
@@ -1545,6 +1546,7 @@ async def run_chat_task(
chat_obj = await Chat.get_by_id(chat_id)
chat_params = (chat_obj.meta or {}).get("params", {}) if chat_obj else {}
agent_workspace = workspace or str(Path.home())
messages, loaded_summary = await _load_message_history(chat_id, message_id)
skill_settings = await get_skill_settings()
skill_authoring_allowed = _has_prior_real_chat_content(messages, loaded_summary)
@@ -1557,7 +1559,7 @@ async def run_chat_task(
)
memory_message, memory_files = _memory_recall_inputs(messages, regeneration_prompt)
system = await _load_system_prompt(
workspace,
agent_workspace,
agent_target.full_model_id,
user_id=user_id,
current_message=memory_message,
@@ -1573,7 +1575,7 @@ async def run_chat_task(
if isinstance(meta_files, list):
current_user_files = meta_files
agent_attachments = await prepare_agent_attachments(
workspace=workspace,
workspace=agent_workspace,
chat_id=chat_id,
message_id=(msg.parent_id if msg and msg.parent_id else message_id),
files=current_user_files,
@@ -1629,7 +1631,7 @@ async def run_chat_task(
async for event in runner(
profile=agent_target.config,
model=agent_target.model,
workspace=workspace,
workspace=agent_workspace,
messages=messages,
system_prompt=system,
chat_params=chat_params,