mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 06:53:14 +00:00
Some checks are pending
CI / Lint (push) Waiting to run
CI / Format check (push) Waiting to run
CI / Unit tests (push) Waiting to run
CI / Playwright E2E (push) Waiting to run
CI / Docker build smoke (push) Waiting to run
CI / Triage ledger up to date (push) Waiting to run
CI / ui bun.lock in sync (push) Waiting to run
* feat: port LangSmith LLM Gateway routing from upstream (#1671, #1673, #1674, #1678) Ports four upstream commits that add opt-in LLM call routing through the LangSmith Gateway, preserving fork conventions (Bedrock/Fireworks model IDs, no-agent-attribution, bun toolchain). - #1671 (e9dc6e01): opt-in gateway routing — new gateway.py, team-settings toggle, admin UI section, wired into make_model for all graph entrypoints - #1673 (702ef908): dedicated LANGSMITH_GATEWAY_API_KEY precedence over platform LANGSMITH_API_KEY - #1674 (5f7c2f46): fix Fireworks gateway base URL to /fireworks (bare host, SDK appends /v1/chat/completions) + SanitizeFireworksMessagesMiddleware - #1678 (73b7d1c0): fix OpenAI Responses reasoning replay — SanitizeOpenAIResponsesMiddleware, store/include config for encrypted reasoning content, reasoning_effort coercion for Chat Completions fallback Refs #134 * fix: downgrade gateway not-routed log to debug, add Bedrock UI note, add sanitizer parity - Downgrade logger.warning to logger.debug in gateway_overrides for not-routed providers and missing API key (Bedrock is the default provider in this fork, so these are expected steady states) - Add Bedrock to the LLMGatewaySection route-toggle description so admins know it is not routed through the gateway - Add SanitizeOpenAIResponsesMiddleware to chat.py for parity with server.py and reviewer.py - Restore the Bedrock region comment in model.py that explains the AWS_REGION / AWS_DEFAULT_REGION precedence Refs #138 --------- Co-authored-by: amoussa1229 <166072409+amoussa1229@users.noreply.github.com>
55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
from langchain_core.messages import AIMessage, HumanMessage
|
|
|
|
from agent.middleware.sanitize_openai_responses import _sanitize_messages
|
|
|
|
|
|
def test_sanitize_messages_drops_stale_reasoning_references() -> None:
|
|
messages = [
|
|
HumanMessage(content="review this"),
|
|
AIMessage(
|
|
content=[
|
|
{
|
|
"type": "reasoning",
|
|
"id": "rs_123",
|
|
"summary": [],
|
|
"content": [],
|
|
},
|
|
{
|
|
"type": "function_call",
|
|
"id": "fc_123",
|
|
"call_id": "call_123",
|
|
"name": "read_file",
|
|
"arguments": "{}",
|
|
},
|
|
],
|
|
tool_calls=[
|
|
{
|
|
"name": "read_file",
|
|
"args": {},
|
|
"id": "call_123",
|
|
}
|
|
],
|
|
),
|
|
]
|
|
|
|
_sanitize_messages(messages)
|
|
|
|
content = messages[1].content
|
|
assert isinstance(content, list)
|
|
assert [block["type"] for block in content] == ["function_call"]
|
|
assert messages[1].tool_calls[0]["id"] == "call_123"
|
|
|
|
|
|
def test_sanitize_messages_preserves_encrypted_reasoning() -> None:
|
|
reasoning = {
|
|
"type": "reasoning",
|
|
"id": "rs_123",
|
|
"encrypted_content": "encrypted",
|
|
"summary": [],
|
|
"content": [],
|
|
}
|
|
messages = [AIMessage(content=[reasoning])]
|
|
|
|
_sanitize_messages(messages)
|
|
|
|
assert messages[0].content == [reasoning]
|