repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
gpt-researcher | deep_agents/report_benchmark.py | .py | """Report-quality benchmark: deep agent + GPT Researcher vs deep agent + raw search.
Short-form QA benchmarks (SimpleQA, FRAMES) measure point-fact lookup, which
is not what a research-report system is for. This benchmark measures the
actual deliverable: given the same research topics, both agents write a
report, and ... | 226 | 9,655 |
gpt-researcher | deep_agents/main.py | .py | from dotenv import load_dotenv
import sys
import os
import json
import uuid
import asyncio
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
load_dotenv()
if os.environ.get("LANGCHAIN_API_KEY"):
os.environ["LANGCHAIN_TRACING_V2"] = "true"
from deep_agents.agent import build_agen... | 101 | 3,226 |
gpt-researcher | deep_agents/recency_benchmark.py | .py | """Recency benchmark: deep agent + GPT Researcher vs deep agent + raw search.
Measures what matters for real-world research: whether an agent's report about
fast-moving topics is CURRENT and CORRECT. Tasks spread across domains where
the ground truth changed after the model's training cutoff - software releases,
AI mo... | 329 | 18,547 |
gpt-researcher | deep_agents/benchmark.py | .py | """Benchmark agents: deep agent + GPT Researcher vs deep agent + raw search.
Defines two deep agents that differ only in their research tooling:
- baseline: the deepagents quickstart setup - a raw Tavily `internet_search`
tool (https://docs.langchain.com/oss/python/deepagents/quickstart).
- gptr: this example's set... | 124 | 5,034 |
gpt-researcher | deep_agents/__init__.py | .py | """Deep Agents x GPT Researcher example.
Runs GPT Researcher as the research engine inside a LangChain Deep Agent
harness: the main agent plans with todos, delegates sections to researcher
subagents with isolated context, offloads drafts to a filesystem, and
assembles a final cited report.
"""
| 8 | 296 |
gpt-researcher | deep_agents/drb_generate.py | .py | """Generate reports for DeepResearch Bench (official harness) from both agents.
Samples English tasks from the official query set (stratified by topic, seeded)
and runs the two deep agents on the raw task prompts, saving outputs in the
benchmark's required raw_data JSONL format:
{"id": ..., "prompt": ..., "article... | 135 | 5,925 |
gpt-researcher | deep_agents/breadth_benchmark.py | .py | """Breadth x depth benchmark: scattered-evidence briefs at fixed agent budgets.
The claim this measures: GPT Researcher gives a deep agent breadth AND depth
in one run. Each `deep_research` call fans out into parallel sub-queries,
scrapes dozens of pages, and returns one distilled, cited digest - so the
main agent cov... | 239 | 13,947 |
gpt-researcher | deep_agents/tools.py | .py | import sys
import os
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from gpt_researcher import GPTResearcher
def build_research_tools(task: dict, cost_tracker: dict | None = None):
"""Build the research tools with the task's source config bound in.
The report source ("we... | 79 | 3,345 |
gpt-researcher | deep_agents/hybrid_benchmark.py | .py | """Hybrid-research benchmark: private documents + web vs web-only tooling.
GPT Researcher's ``hybrid`` mode runs the same research pipeline over local
documents (via DOC_PATH) and the web simultaneously. This benchmark measures
what that is worth against two stock-deepagents alternatives:
- ``baseline``: raw Tavily w... | 238 | 10,255 |
gpt-researcher | deep_agents/agent.py | .py | import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from deepagents import create_deep_agent
from deepagents.backends import FilesystemBackend
from deep_agents.tools import build_research_tools
CHIEF_EDITOR_PROMPT = """You are the Chief Editor of an autonomous res... | 90 | 3,936 |
gpt-researcher | deep_agents/benchmark_data/build_corpus.py | .py | """Build the realistic internal-documents corpus for the hybrid benchmark.
Takes the four ground-truth documents in ``internal_docs_src/`` and produces
``internal_docs/``, a corpus shaped like a real company document share:
- The fact documents are converted to the formats such documents actually
ship in: PDF (boar... | 372 | 14,067 |
gpt-researcher | evals/simple_evals/simpleqa_eval.py | .py | """
SimpleQA: Measuring short-form factuality in large language models
Adapted for GPT-Researcher from OpenAI's simple-evals
"""
import os
import re
import json
import pandas
import random
from typing import Dict, List, Any
from langchain_openai import ChatOpenAI
GRADER_TEMPLATE = """
Your job is to look at a questio... | 172 | 9,470 |
gpt-researcher | evals/simple_evals/run_eval.py | .py | import asyncio
import os
import sys
import argparse
import json
import subprocess
# Ensure Unicode output works on Windows terminals (GBK → UTF-8)
if sys.stdout.encoding and sys.stdout.encoding.lower() != "utf-8":
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
import time
from datetime import datetime,... | 259 | 10,601 |
gpt-researcher | evals/hallucination_eval/evaluate.py | .py | """
Evaluate model outputs for hallucination using the judges library.
"""
import logging
from pathlib import Path
from typing import Dict, List, Optional
from dotenv import load_dotenv
from judges.classifiers.hallucination import HaluEvalDocumentSummaryNonFactual
# Configure logging
logging.basicConfig(
level=lo... | 74 | 2,483 |
gpt-researcher | evals/hallucination_eval/run_eval.py | .py | """
Script to run GPT-Researcher queries and evaluate them for hallucination.
"""
import json
import logging
import random
import asyncio
import argparse
import os
from pathlib import Path
from typing import Dict, List, Optional
from dotenv import load_dotenv
from gpt_researcher.agent import GPTResearcher
from gpt_res... | 229 | 7,753 |
agentscope | tests/rag_chunker_approx_token_test.py | .py | # -*- coding: utf-8 -*-
"""Unit tests for the ApproxTokenChunker class."""
from unittest.async_case import IsolatedAsyncioTestCase
from utils import AnyString
from agentscope.message import Base64Source, DataBlock, TextBlock
from agentscope.rag import ApproxTokenChunker, Chunk, Section
def _dump_chunks(chunks: list... | 221 | 7,388 |
agentscope | tests/console_renderer_test.py | .py | # -*- coding: utf-8 -*-
"""Console renderer test cases."""
from io import StringIO
from unittest import TestCase
from rich.console import Console
from agentscope.console import ConsoleRenderer
from agentscope.event import (
HintBlockEvent,
ModelCallEndEvent,
ReplyEndEvent,
ReplyStartEvent,
Require... | 310 | 10,956 |
agentscope | tests/service_chat_middleware_factory_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Back-compat probe for the ``extra_agent_middlewares`` factory.
The factory gained a fourth ``workspace`` argument. ``ChatService`` probes
each factory's signature once at construction so factories written against
the original three-argument shape keep being... | 97 | 3,146 |
agentscope | tests/service_toolkit_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Tests for :func:`get_toolkit` — the single entry point that assembles
the per-chat-turn :class:`Toolkit` from every tool source the framework
manages.
Verifies the assembly rules:
- workspace builtins are always included;
- the four ``Task*`` planning tool... | 422 | 14,642 |
agentscope | tests/embedding_gemini_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Unit tests for GeminiEmbeddingModel."""
from dataclasses import asdict
from typing import Any
from unittest import IsolatedAsyncioTestCase
from unittest.mock import AsyncMock
from utils import AnyValue
from agentscope.embedding import (
GeminiEmbedding... | 180 | 6,346 |
agentscope | tests/model_openai_response_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Unit tests for OpenAIResponseModel with mocked API responses.
Tests cover both non-streaming and streaming modes.
OpenAI Responses API uses event-based streaming with response.completed.
"""
from typing import Any
import unittest
from unittest import Isolat... | 747 | 23,775 |
agentscope | tests/compress_context_test.py | .py | # -*- coding: utf-8 -*-
"""A template test case."""
# pylint: disable=protected-access
import json
import os
import tempfile
from typing import Any
from unittest.async_case import IsolatedAsyncioTestCase
from utils import MockModel, AnyString
from agentscope.model import StructuredResponse
from agentscope.agent impo... | 1,389 | 48,414 |
agentscope | tests/_daytona_live_utils.py | .py | # -*- coding: utf-8 -*-
"""Shared helpers for optional live Daytona tests."""
import os
import uuid
from agentscope.workspace._daytona._constants import METADATA_WORKSPACE_ID_KEY
DAYTONA_API_KEY = os.getenv("DAYTONA_API_KEY", "")
DAYTONA_API_URL = os.getenv("DAYTONA_API_URL", "")
DAYTONA_TARGET = os.getenv("DAYTONA_... | 51 | 1,634 |
agentscope | tests/service_mcp_render_test.py | .py | # -*- coding: utf-8 -*-
"""MCP card rendering test case."""
from unittest import TestCase
from agentscope.app._service import MCPRenderError, render_mcp
from agentscope.app.hub import MCPCard
API_KEY_SCHEMA = {
"type": "object",
"properties": {
"api_key": {
"type": "string",
"w... | 259 | 8,001 |
agentscope | tests/model_deepseek_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Unit tests for DeepSeekChatModel with mocked API responses.
Tests cover both non-streaming and streaming modes, verifying that:
- Non-stream mode returns a single ChatResponse with is_last=True.
- Stream mode yields n delta ChatResponses (is_last=False) fol... | 732 | 23,385 |
agentscope | tests/workspace_opensandbox_test.py | .py | # -*- coding: utf-8 -*-
"""Test cases for OpenSandboxWorkspace.
The whole module is skipped when the ``OPENSANDBOX_DOMAIN`` environment
variable is not set, because every test requires a live OpenSandbox
service.
"""
import os
import unittest
from unittest.async_case import IsolatedAsyncioTestCase
from agentscope.mcp... | 74 | 2,506 |
agentscope | tests/model_dashscope_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Unit tests for DashScopeChatModel with mocked API responses.
Tests cover both non-streaming and streaming modes.
"""
import base64
import io
import wave
from typing import Any
import unittest
from unittest import IsolatedAsyncioTestCase
from unittest.mock i... | 651 | 20,637 |
agentscope | tests/service_wakeup_dispatcher_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Tests for :class:`WakeupDispatcher` — one-per-process consumer of the
shared wake-up queue + signal channel.
Verifies the four behaviours that callers rely on:
- Lifecycle is purely ACM: ``__aenter__`` starts the loop and performs
an initial drain; ``__a... | 534 | 17,290 |
agentscope | tests/reme_middleware_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access,unused-argument
"""Unit tests for ReMeMiddleware.
The embedded ReMe app is mocked — we only exercise the AgentScope hook
wiring (retrieve-before / write-after, system-prompt injection,
list_tools exposure) and the small adapters that translate between
AgentSco... | 1,243 | 45,875 |
agentscope | tests/service_message_bus_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Tests for :class:`RedisMessageBus` and the domain helpers on the base
:class:`MessageBus` class.
The Redis backend is exercised against ``fakeredis`` so tests cover both
the abstract surface (queue / log / pubsub / lock) and the domain helpers
(``session_ru... | 592 | 23,426 |
agentscope | tests/id_factory_test.py | .py | # -*- coding: utf-8 -*-
"""Tests for the configurable ID factory."""
import re
from unittest.async_case import IsolatedAsyncioTestCase
from agentscope import set_id_factory
from agentscope.message import Msg, TextBlock
_HEX32_RE = re.compile(r"^[0-9a-f]{32}$")
class IdFactoryTest(IsolatedAsyncioTestCase):
"""Te... | 50 | 1,628 |
agentscope | tests/hub_github_test.py | .py | # -*- coding: utf-8 -*-
"""GitHub MCP registry card-building test case, without any network."""
from unittest import TestCase
from agentscope.app._service import render_mcp
from agentscope.app.hub import GitHubMCPHub
class GitHubCardTest(TestCase):
"""Turning a registry entry into an ``MCPCard``."""
def set... | 280 | 10,308 |
agentscope | tests/utils.py | .py | # -*- coding: utf-8 -*-
"""The utility module for unit tests in agentscope."""
import json
from typing import Any, AsyncGenerator, Type
from pydantic import BaseModel
from agentscope.app.workspace_manager import WorkspaceManagerBase
from agentscope.credential import CredentialBase
from agentscope.formatter import For... | 193 | 6,180 |
agentscope | tests/tts_dashscope_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Unit tests for the TTS module.
Covers:
* ``TTSModelBase`` default no-op behaviour for ``connect`` / ``close`` /
``push`` (so non-realtime subclasses needn't override them).
* ``DashScopeTTSModel`` non-streaming aggregation.
* ``DashScopeTTSModel``... | 1,441 | 56,096 |
agentscope | tests/toolkit_task_test.py | .py | # -*- coding: utf-8 -*-
"""Unit tests for task tools executed through toolkit."""
import json
from typing import Any
from unittest.async_case import IsolatedAsyncioTestCase
from utils import AnyString
from agentscope.message import ToolCallBlock
from agentscope.state import AgentState
from agentscope.tool import (
... | 1,228 | 39,317 |
agentscope | tests/model_count_tokens_test.py | .py | # -*- coding: utf-8 -*-
"""Tests for the fallback chat model token estimation."""
from unittest.async_case import IsolatedAsyncioTestCase
from utils import MockModel
from agentscope.message import (
Base64Source,
DataBlock,
TextBlock,
URLSource,
UserMsg,
)
class ModelCountTokensTest(IsolatedAsyn... | 85 | 2,617 |
agentscope | tests/hitl_mixed_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=redefined-builtin
"""Test mixed user confirmation and external execution in the agent."""
from typing import Any
from unittest.async_case import IsolatedAsyncioTestCase
from utils import AnyString, MockModel
from agentscope.agent import Agent, InjectionConfig
from agentscope.... | 1,231 | 41,053 |
agentscope | tests/compress_tool_result_test.py | .py | # -*- coding: utf-8 -*-
"""The unittests for the tool result compression."""
# pylint: disable=protected-access, unused-argument
from unittest.async_case import IsolatedAsyncioTestCase
from utils import MockModel, AnyString
from agentscope.agent import Agent, ContextConfig
from agentscope.message import (
ToolRes... | 577 | 17,806 |
agentscope | tests/tool_offload_middleware_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Unit tests for ToolOffloadMiddleware."""
import asyncio
import json
from typing import Any
from unittest.async_case import IsolatedAsyncioTestCase
from unittest.mock import AsyncMock, MagicMock
from pydantic import BaseModel
from utils import AnyString, M... | 413 | 13,697 |
agentscope | tests/toolkit_skill_test.py | .py | # -*- coding: utf-8 -*-
"""Test cases for Toolkit skill-related functionality."""
import json
import os
import tempfile
from unittest.async_case import IsolatedAsyncioTestCase
from utils import AnyString
from agentscope.skill import SkillLoaderBase, Skill
from agentscope.tool import Toolkit, ToolChunk, ToolResponse, ... | 417 | 14,292 |
agentscope | tests/builtin_powershell_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""PowerShell tool test cases."""
import base64
import sys
import unittest
from unittest.async_case import IsolatedAsyncioTestCase
from unittest.mock import AsyncMock
from agentscope.permission import PermissionBehavior, PermissionContext
from agentscope.tool... | 383 | 12,343 |
agentscope | tests/backend_e2b_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Test cases for :class:`E2BBackend`.
Validates that the three backend primitives (``exec_shell``,
``read_file``, ``write_file``) and the inherited shell-based filesystem
helpers behave correctly inside a real E2B cloud sandbox.
The whole module is skipped u... | 150 | 6,824 |
agentscope | tests/hub_card_test.py | .py | # -*- coding: utf-8 -*-
"""Hub card identity test case."""
from unittest import TestCase
from agentscope.app.hub import HubBase, MCPCard, SkillCard
HTTP_CONFIG = {"type": "http_mcp", "url": "https://example.com/sse"}
class HubIdentityTest(TestCase):
"""Hub id validation."""
def test_accepts_plain_id(self) ... | 98 | 3,085 |
agentscope | tests/app_lifespan_dedicated_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""End-to-end wiring test for dedicated-deployment knowledge-base upload.
Boots the FastAPI app with ``enable_index_worker=False`` so the API
process does NOT host an :class:`IndexWorker`. Dispatch happens
through the message bus: a ``MessageBusDispatcher`` wr... | 336 | 11,103 |
agentscope | tests/formatter_gemini_test.py | .py | # -*- coding: utf-8 -*-
"""Comprehensive formatter unit tests for GeminiChatFormatter and
GeminiMultiAgentFormatter, following the reference test style with exact
ground-truth comparisons.
"""
from unittest import IsolatedAsyncioTestCase
from unittest.mock import patch
from agentscope.formatter import (
GeminiChat... | 783 | 26,730 |
agentscope | tests/hub_router_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=too-many-public-methods
"""Hub router test case — browse and install, without any network."""
import io
import json
import tempfile
import zipfile
from typing import Any, AsyncIterator
from unittest import IsolatedAsyncioTestCase
import fakeredis.aioredis
from fastapi.testclie... | 850 | 30,115 |
agentscope | tests/service_index_task_consumer_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Tests for :class:`IndexTaskConsumer` — the worker-process side of
the message-bus index dispatch flow.
Verifies the four behaviours callers rely on:
- Lifecycle is purely ACM: ``__aenter__`` starts the loop and performs
an initial drain; ``__aexit__`` ca... | 418 | 13,371 |
agentscope | tests/toolkit_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=unused-argument
"""Toolkit test case."""
import base64
import json
from typing import Any, AsyncGenerator, Generator
from unittest import TestCase
from unittest.async_case import IsolatedAsyncioTestCase
from utils import AnyString
from agentscope.mcp import HttpMCPConfig, MC... | 1,459 | 45,789 |
agentscope | tests/embedding_ollama_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Unit tests for OllamaEmbeddingModel."""
from dataclasses import asdict
from typing import Any
from unittest import IsolatedAsyncioTestCase
from unittest.mock import AsyncMock
from utils import AnyValue
from agentscope.credential import OllamaCredential
fro... | 107 | 3,328 |
agentscope | tests/builtin_file_cache_test.py | .py | # -*- coding: utf-8 -*-
"""File cache test case for Read/Write/Edit tools."""
import os
import tempfile
from unittest.async_case import IsolatedAsyncioTestCase
from agentscope.state import AgentState
from agentscope.tool import Read, Write, Edit
class FileCacheTest(IsolatedAsyncioTestCase):
"""Test file cache fu... | 433 | 14,925 |
agentscope | tests/service_inbox_handoff_test.py | .py | # -*- coding: utf-8 -*-
"""Tests for the session-inbox hand-off protocol in ``_bus_ops``.
The protocol exists so a payload pushed to a session inbox is always
consumed by *some* run, instead of sitting there until the next user
turn. Producers and the finishing run coordinate through one lock:
- :func:`deliver_to_inb... | 163 | 6,155 |
agentscope | tests/agent_interrupt_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=redefined-builtin
"""Tests for agent interruption:
- :class:`AgentInterruptCancelTest`: ``task.cancel()`` lands during tool
execution and the agent must close every pending tool call with an
``INTERRUPTED`` result and end the reply with
``ReplyEndReason.INTERRUPTED``.
- ... | 1,011 | 33,137 |
agentscope | tests/test_template.py | .py | # -*- coding: utf-8 -*-
"""A template test case."""
from unittest.async_case import IsolatedAsyncioTestCase
class TemplateTest(IsolatedAsyncioTestCase):
"""The template test case."""
async def asyncSetUp(self) -> None:
"""The async setup method."""
async def test_template(self) -> None:
... | 17 | 430 |
agentscope | tests/agent_structured_output_test.py | .py | # -*- coding: utf-8 -*-
"""Test the agent-level structured output."""
from typing import Any
from unittest.async_case import IsolatedAsyncioTestCase
from pydantic import BaseModel
from utils import AnyString, MockModel
from agentscope.agent import Agent, InjectionConfig, ReActConfig
from agentscope.model import ChatR... | 491 | 17,504 |
agentscope | tests/builtin_bash_test.py | .py | # -*- coding: utf-8 -*-
"""Bash tool test case."""
import os
import sys
import unittest
from unittest.async_case import IsolatedAsyncioTestCase
from unittest.mock import AsyncMock, MagicMock, patch
from agentscope.message import TextBlock
from agentscope.permission import (
PermissionBehavior,
PermissionConte... | 560 | 19,616 |
agentscope | tests/health_router_test.py | .py | # -*- coding: utf-8 -*-
"""Health router test case — readiness reporting, without any I/O."""
import tempfile
from typing import Any
from unittest import IsolatedAsyncioTestCase
import fakeredis.aioredis
from fastapi.testclient import TestClient
from agentscope.app import create_app
from agentscope.app.message_bus im... | 112 | 4,309 |
agentscope | tests/hitl_external_execution_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=redefined-builtin
"""Test the external execution events in the agent class."""
from typing import Any
from unittest.async_case import IsolatedAsyncioTestCase
from utils import AnyString, MockModel
from agentscope.agent import Agent, InjectionConfig
from agentscope.model impor... | 1,477 | 52,388 |
agentscope | tests/workspace_manager_daytona_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Test cases for :class:`DaytonaWorkspaceManager`."""
import asyncio
import unittest
from types import SimpleNamespace
from unittest.async_case import IsolatedAsyncioTestCase
from unittest.mock import AsyncMock, patch
from agentscope.app.workspace_manager im... | 207 | 7,163 |
agentscope | tests/mcp_client_reconnect_test.py | .py | # -*- coding: utf-8 -*-
"""Tests for reconnecting stateful MCP clients."""
from types import TracebackType
from typing import Any
from unittest.async_case import IsolatedAsyncioTestCase
from unittest.mock import patch
from agentscope.mcp import HttpMCPConfig, MCPClient, StdioMCPConfig
class _OneShotTransport:
""... | 163 | 5,454 |
agentscope | tests/workspace_daytona_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Test cases for :class:`DaytonaWorkspace`.
Most tests patch the Daytona SDK boundary so they run in normal CI.
Live tests are opt-in via ``DAYTONA_API_KEY``.
"""
import asyncio
import json
import os
import shlex
import shutil
import sys
import tempfile
impo... | 1,742 | 60,270 |
agentscope | tests/model_xai_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Unit tests for XAIChatModel with mocked API responses.
Tests cover both non-streaming and streaming modes.
XAI uses xai_sdk with chat.stream() for streaming.
"""
import sys
from typing import Any
from types import ModuleType
import unittest
from unittest im... | 664 | 20,975 |
agentscope | tests/service_agent_interrupt_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=missing-class-docstring,missing-function-docstring
"""Service-layer integration tests for the agent interruption pipeline.
Covers the plumbing that translates an external interrupt signal into a
local ``task.cancel()``:
message bus publish
→ ``CancelDispatcher`` (... | 253 | 8,738 |
agentscope | tests/workspace_local_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Test cases for LocalWorkspace."""
import os
import json
import base64
import hashlib
import tempfile
from types import SimpleNamespace
from typing import Any
from unittest.async_case import IsolatedAsyncioTestCase
from unittest.mock import AsyncMock, patch
f... | 2,000 | 73,423 |
agentscope | tests/agui_protocol_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Test cases for AGUI protocol middleware."""
import json
from typing import AsyncGenerator
from unittest.async_case import IsolatedAsyncioTestCase
from unittest.mock import MagicMock
from fastapi import FastAPI
from fastapi.responses import JSONResponse
fro... | 728 | 25,376 |
agentscope | tests/model_anthropic_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Unit tests for AnthropicChatModel with mocked API responses.
Tests cover both non-streaming and streaming modes.
Anthropic uses event-based streaming (message_start, content_block_start,
content_block_delta, message_delta events).
"""
import json
from typin... | 929 | 30,264 |
agentscope | tests/formatter_anthropic_test.py | .py | # -*- coding: utf-8 -*-
"""Comprehensive formatter unit tests for AnthropicChatFormatter and
AnthropicMultiAgentFormatter, following the reference test style with exact
ground-truth comparisons.
"""
from unittest import IsolatedAsyncioTestCase
from agentscope.formatter import (
AnthropicChatFormatter,
Anthropi... | 1,212 | 41,463 |
agentscope | tests/model_ollama_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Unit tests for OllamaChatModel with mocked API responses.
Tests cover both non-streaming and streaming modes.
Ollama uses ollama.AsyncClient with async iterator streaming.
"""
import json
from typing import Any
import unittest
from unittest import IsolatedA... | 402 | 11,886 |
agentscope | tests/service_scheduler_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Tests for :meth:`SchedulerManager._build_trigger`.
We don't drive APScheduler here — we ask the manager to build a trigger
coroutine for a record and invoke it directly. The trigger's contract is:
- when ``ScheduleData.enabled`` is False → no side effects;... | 270 | 8,763 |
agentscope | tests/test_e2e_docker_mcp.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""E2E test: per-scope MCP isolation via DockerWorkspace.
Requires: Docker running locally.
"""
import json
import os
import shutil
import subprocess
import sys
import tempfile
import unittest
from agentscope.workspace import DockerWorkspace
from agentscope.m... | 252 | 8,213 |
agentscope | tests/formatter_deepseek_test.py | .py | # -*- coding: utf-8 -*-
"""Comprehensive formatter unit tests for DeepSeekChatFormatter and
DeepSeekMultiAgentFormatter, with exact ground-truth comparisons.
"""
from unittest import IsolatedAsyncioTestCase
from agentscope.formatter import (
DeepSeekChatFormatter,
DeepSeekMultiAgentFormatter,
)
from agentscope... | 533 | 18,299 |
agentscope | tests/permission_bash_parser_test.py | .py | # -*- coding: utf-8 -*-
"""Test cases for BashCommandParser."""
import sys
import unittest
from unittest.async_case import IsolatedAsyncioTestCase
from agentscope.tool._builtin._bash_parser import BashCommandParser
from agentscope.tool import Bash
@unittest.skipIf(
sys.platform == "win32",
"Bash tool is not ... | 1,345 | 50,694 |
agentscope | tests/service_team_tools_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Tests for the four framework-builtin team tools — :class:`TeamCreate`,
:class:`AgentCreate`, :class:`TeamSay`, :class:`TeamDelete`.
Each tool's business logic now lives inline in its ``__call__`` (the
old ``TeamService`` orchestration layer is gone), so uni... | 1,786 | 63,624 |
agentscope | tests/model_response_test.py | .py | # -*- coding: utf-8 -*-
"""Unit tests for :class:`agentscope.model.ChatResponse` and its
``append_*`` helpers."""
from unittest.async_case import IsolatedAsyncioTestCase
from utils import AnyString
from agentscope.message import TextBlock
from agentscope.model import ChatResponse, FinishedReason, ChatUsage
def _dum... | 477 | 16,644 |
agentscope | tests/middleware_budget_test.py | .py | # -*- coding: utf-8 -*-
"""Unit tests for BudgetControlMiddleware."""
from typing import Any
from unittest.async_case import IsolatedAsyncioTestCase
from utils import MockModel
from agentscope.agent import Agent
from agentscope.message import UserMsg, TextBlock, ToolCallBlock, HintBlock
from agentscope.middleware impo... | 477 | 16,358 |
agentscope | tests/builtin_grep_test.py | .py | # -*- coding: utf-8 -*-
"""Grep tool test case."""
import os
import tempfile
from unittest.async_case import IsolatedAsyncioTestCase
from agentscope.message import ToolResultState
from agentscope.tool import Grep
from agentscope.permission import (
PermissionContext,
PermissionBehavior,
PermissionRule,
)
... | 255 | 8,304 |
agentscope | tests/agent_injection_test.py | .py | # -*- coding: utf-8 -*-
"""Unit tests for the runtime state injection of the agent, i.e. the
``Agent._inject_runtime_state`` method."""
from datetime import datetime, tzinfo
from unittest.async_case import IsolatedAsyncioTestCase
from unittest.mock import AsyncMock, patch
from pydantic import ValidationError
from uti... | 382 | 15,586 |
agentscope | tests/mcp_streamable_http_client_test.py | .py | # -*- coding: utf-8 -*-
"""The MCP client test module in agentscope."""
import asyncio
from multiprocessing import Process
from unittest.async_case import IsolatedAsyncioTestCase
from mcp.server import FastMCP
from mcp.types import EmbeddedResource, TextResourceContents
from agentscope.mcp import MCPClient, HttpMCPCo... | 148 | 4,392 |
agentscope | tests/builtin_glob_test.py | .py | # -*- coding: utf-8 -*-
"""Glob tool test case."""
import os
import tempfile
from unittest.async_case import IsolatedAsyncioTestCase
from utils import AnyString
from agentscope.tool import Glob
from agentscope.permission import (
PermissionContext,
PermissionBehavior,
PermissionRule,
)
class GlobToolTest... | 239 | 7,721 |
agentscope | tests/middleware_filesystem_memory_test.py | .py | # -*- coding: utf-8 -*-
"""Unit tests for AgenticMemoryMiddleware with real Agent execution."""
import os
import shutil
import tempfile
from typing import Any, Type
from unittest.async_case import IsolatedAsyncioTestCase
from pydantic import BaseModel
from utils import AnyString, AnyValue, MockModel
from agentscope.a... | 777 | 24,989 |
agentscope | tests/workspace_skill_archive_test.py | .py | # -*- coding: utf-8 -*-
"""Test cases for installing a skill from an archive stream."""
import io
import os
import tarfile
import tempfile
import zipfile
from typing import AsyncIterator
from unittest.async_case import IsolatedAsyncioTestCase
from fastapi import UploadFile
from agentscope.app._service import Workspac... | 304 | 11,372 |
agentscope | tests/model_openai_chat_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Unit tests for OpenAIChatModel with mocked API responses.
Tests cover both non-streaming and streaming modes, verifying that:
- Non-stream mode returns a single ChatResponse with is_last=True.
- Stream mode yields n delta ChatResponses (is_last=False) follo... | 837 | 27,263 |
agentscope | tests/event_test.py | .py | # -*- coding: utf-8 -*-
"""Event test"""
from unittest.async_case import IsolatedAsyncioTestCase
from utils import AnyString
from agentscope.event import ReplyStartEvent
class EventTest(IsolatedAsyncioTestCase):
"""The event test case."""
async def asyncSetUp(self) -> None:
"""The async setup method.... | 51 | 1,502 |
agentscope | tests/formatter_ollama_test.py | .py | # -*- coding: utf-8 -*-
"""Comprehensive formatter unit tests for OllamaChatFormatter and
OllamaMultiAgentFormatter, with exact ground-truth comparisons.
"""
from unittest import IsolatedAsyncioTestCase
from unittest.mock import patch
from agentscope.formatter import OllamaChatFormatter, OllamaMultiAgentFormatter
from... | 648 | 22,369 |
agentscope | tests/rag_vdb_qdrant_test.py | .py | # -*- coding: utf-8 -*-
"""Unit tests for the QdrantStore class."""
from contextlib import AsyncExitStack
from unittest.async_case import IsolatedAsyncioTestCase
from utils import AnyString
from agentscope.message import TextBlock
from agentscope.rag import (
Chunk,
QdrantStore,
VectorRecord,
VectorSe... | 385 | 12,448 |
agentscope | tests/workspace_e2b_test.py | .py | # -*- coding: utf-8 -*-
"""Test cases for E2BWorkspace.
The whole module is skipped when the ``E2B_API_KEY`` environment variable is
not set, because every test requires a live E2B cloud sandbox.
"""
import os
import unittest
from unittest.async_case import IsolatedAsyncioTestCase
from agentscope.mcp import MCPClient... | 76 | 2,649 |
agentscope | tests/middleware_rag_test.py | .py | # -*- coding: utf-8 -*-
"""Unit tests for the :class:`RAGMiddleware` class."""
from contextlib import AsyncExitStack
from types import SimpleNamespace
from typing import Any, AsyncGenerator
from unittest.async_case import IsolatedAsyncioTestCase
from utils import AnyString
from agentscope.embedding import EmbeddingRe... | 553 | 19,079 |
agentscope | tests/builtin_edit_test.py | .py | # -*- coding: utf-8 -*-
"""Edit tool test case."""
import os
import tempfile
from unittest.async_case import IsolatedAsyncioTestCase
from agentscope.tool import Edit
from agentscope.permission import (
PermissionContext,
PermissionBehavior,
PermissionRule,
)
class EditToolTest(IsolatedAsyncioTestCase):
... | 183 | 5,973 |
agentscope | tests/model_gemini_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Unit tests for GeminiChatModel with mocked API responses.
Tests cover both non-streaming and streaming modes.
Gemini uses google.genai client with async iterator streaming.
"""
import json
from typing import Any
import unittest
from unittest import Isolated... | 798 | 25,844 |
agentscope | tests/embedding_openai_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Unit tests for OpenAIEmbeddingModel."""
from dataclasses import asdict
from typing import Any
from unittest import IsolatedAsyncioTestCase
from unittest.mock import AsyncMock, MagicMock, patch
from utils import AnyValue
from agentscope.credential import Op... | 184 | 5,953 |
agentscope | tests/rag_vdb_mongodb_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access,missing-function-docstring
"""Unit tests for the MongoDBStore class (mocked pymongo backend)."""
from __future__ import annotations
import math
from contextlib import AsyncExitStack
from typing import Any
from unittest.async_case import IsolatedAsyncioTestCase... | 660 | 21,269 |
agentscope | tests/in_memory_message_bus_test.py | .py | # -*- coding: utf-8 -*-
"""Tests for :class:`InMemoryMessageBus`.
The same abstract surface exercised in ``service_message_bus_test.py``
(queue / log / pubsub / lock / registry) is tested here against the
pure-Python in-memory backend, plus the domain helpers inherited from
the base :class:`MessageBus` class.
No exte... | 504 | 19,697 |
agentscope | tests/test_e2e_api.py | .py | # -*- coding: utf-8 -*-
"""E2E test: per-scope MCP isolation via HTTP API (pytest).
Requires: Redis running on localhost:6379
"""
# pylint: disable=redefined-outer-name
import asyncio
import tempfile
import os
import threading
import httpx
import pytest
import redis.asyncio as aioredis
import uvicorn
from agentscope... | 321 | 10,123 |
agentscope | tests/tracing_test.py | .py | # -*- coding: utf-8 -*-
"""Unit tests for the tracing module using an in-memory OTel exporter."""
import asyncio
import json
from typing import Any
from unittest.async_case import IsolatedAsyncioTestCase
from opentelemetry import trace as otel_trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry... | 913 | 31,769 |
agentscope | tests/rag_parser_test.py | .py | # -*- coding: utf-8 -*-
"""Unit tests for the file parsers in :mod:`agentscope.rag._parser`.
PDF / PPTX fixtures are produced in-memory via :mod:`reportlab` and
:mod:`python-pptx` so the tests have no on-disk dependencies and can
run anywhere ``agentscope[rag]`` is installed.
"""
import base64
import io
import os
from... | 1,287 | 44,840 |
agentscope | tests/channel_gateway_test.py | .py | # -*- coding: utf-8 -*-
"""Tests for channel data-plane internals that stand alone from a live run.
Covers the channel's event-stream folding (``send_response`` driven off a
seeded event list via a fake channel), the gateway's media aggregation,
and the text-confirmation reply parser. Full two-phase orchestration
need... | 417 | 13,709 |
agentscope | tests/permission_mode_test.py | .py | # -*- coding: utf-8 -*-
"""Per-mode test cases for ``PermissionEngine``.
Each :class:`PermissionMode` has its own test class so the policy of
that mode can be verified in isolation. Tests cover:
- the three rule layers (deny / ask / allow) for that mode
- the ``tool.check_permissions`` return paths (ALLOW / DENY / sa... | 1,062 | 40,091 |
agentscope | tests/middleware_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=abstract-method,protected-access
"""Unit tests for middleware system."""
from unittest.async_case import IsolatedAsyncioTestCase
from unittest.mock import AsyncMock, patch
from typing import Any, AsyncGenerator, Awaitable, Callable, Union
from utils import AnyString, MockModel... | 1,979 | 69,003 |
agentscope | tests/storage_redis_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
"""Unit tests for RedisStorage using fakeredis."""
from unittest.async_case import IsolatedAsyncioTestCase
import fakeredis.aioredis
from agentscope.app.storage import (
RedisStorage,
AgentRecord,
SessionConfig,
SessionRecord,
ChatModelCo... | 1,521 | 55,216 |
agentscope | tests/backend_applecontainer_test.py | .py | # -*- coding: utf-8 -*-
# pylint: disable=protected-access
# mypy: disable-error-code="misc,no-untyped-def,attr-defined"
"""Test cases for :class:`AppleContainerBackend`.
Runs against a real Apple Container via the ``container`` CLI.
Requires ``container`` CLI installed and ``container system start``
running.
"""
imp... | 461 | 17,730 |
agentscope | tests/index_worker_lease_test.py | .py | # -*- coding: utf-8 -*-
"""Regression tests for :class:`IndexWorker.process` lease handling.
The pipeline must stop the moment the lease has been stolen by the
sweeper — otherwise the original worker and the worker that just took
over both write the same document into the vector store, producing
duplicate chunks (PR #... | 197 | 6,976 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.