Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added __init__.py
Empty file.
4 changes: 4 additions & 0 deletions __main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import runpy

if __name__ == "__main__":
runpy.run_module("seclab_taskflow_agent.main", run_name="__main__")
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The module name 'seclab_taskflow_agent.main' is hardcoded and doesn't match the actual package structure. This should use a relative import or derive the module name dynamically to avoid breaking if the package is renamed.

Suggested change
runpy.run_module("seclab_taskflow_agent.main", run_name="__main__")
module_name = (__package__ + ".main") if __package__ else "main"
runpy.run_module(module_name, run_name="__main__")

Copilot uses AI. Check for mistakes.
Comment thread
sylwia-budzynska marked this conversation as resolved.
2 changes: 1 addition & 1 deletion agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from agents.run import RunHooks
from agents import Agent, Runner, AgentHooks, RunHooks, result, function_tool, Tool, RunContextWrapper, TContext, OpenAIChatCompletionsModel, set_default_openai_client, set_default_openai_api, set_tracing_disabled

from capi import COPILOT_INTEGRATION_ID, COPILOT_API_ENDPOINT
from .capi import COPILOT_INTEGRATION_ID, COPILOT_API_ENDPOINT

# grab our secrets from .env, this must be in .gitignore
load_dotenv()
Expand Down
26 changes: 16 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import json
import uuid

from agent import DEFAULT_MODEL, TaskRunHooks, TaskAgentHooks
from .agent import DEFAULT_MODEL, TaskRunHooks, TaskAgentHooks
#from agents.run import DEFAULT_MAX_TURNS # XXX: this is 10, we need more than that
from agents.exceptions import MaxTurnsExceeded, AgentsException
from agents.agent import ModelSettings
Expand All @@ -22,21 +22,27 @@
from openai.types.responses import ResponseTextDeltaEvent
from typing import Any

from shell_utils import shell_tool_call
from mcp_utils import DEFAULT_MCP_CLIENT_SESSION_TIMEOUT, ReconnectingMCPServerStdio, AsyncDebugMCPServerStdio, MCPNamespaceWrap, mcp_client_params, mcp_system_prompt, StreamableMCPThread
from render_utils import render_model_output, flush_async_output
from env_utils import TmpEnv
from yaml_parser import YamlParser
from agent import TaskAgent
from capi import list_tool_call_models
from available_tools import AvailableTools
from .shell_utils import shell_tool_call
from .mcp_utils import DEFAULT_MCP_CLIENT_SESSION_TIMEOUT, ReconnectingMCPServerStdio, AsyncDebugMCPServerStdio, MCPNamespaceWrap, mcp_client_params, mcp_system_prompt, StreamableMCPThread
from .render_utils import render_model_output, flush_async_output
from .env_utils import TmpEnv
from .yaml_parser import YamlParser
from .agent import TaskAgent
from .capi import list_tool_call_models
from .available_tools import AvailableTools

load_dotenv()

# only model output or help message should go to stdout, everything else goes to log
logging.getLogger('').setLevel(logging.NOTSET)

# Create logs directory if it doesn't exist
# This is needed when running the code as a package from any directory
log_dir = os.path.join(os.getcwd(), 'logs')
Comment thread
sylwia-budzynska marked this conversation as resolved.
Comment thread
sylwia-budzynska marked this conversation as resolved.
os.makedirs(log_dir, exist_ok=True)

log_file_handler = RotatingFileHandler(
'logs/task_agent.log',
os.path.join(log_dir, 'task_agent.log'),
maxBytes=1024*1024*10,
backupCount=10)
log_file_handler.setLevel(os.getenv('TASK_AGENT_LOGLEVEL', default='DEBUG'))
Expand Down
2 changes: 1 addition & 1 deletion mcp_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from mcp.types import CallToolResult, TextContent
from agents.mcp import MCPServerStdio

from env_utils import swap_env
from .env_utils import swap_env

DEFAULT_MCP_CLIENT_SESSION_TIMEOUT = 120

Expand Down