Skip to content

Commit 58caf3f

Browse files
Fix relative paths and imports to make code work as a package
1 parent fe79430 commit 58caf3f

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed

__init__.py

Whitespace-only changes.

__main__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import runpy
2+
3+
if __name__ == "__main__":
4+
runpy.run_module("seclab_taskflow_agent.main", run_name="__main__")

agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from agents.run import RunHooks
1313
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
1414

15-
from capi import COPILOT_INTEGRATION_ID, COPILOT_API_ENDPOINT
15+
from .capi import COPILOT_INTEGRATION_ID, COPILOT_API_ENDPOINT
1616

1717
# grab our secrets from .env, this must be in .gitignore
1818
load_dotenv()

main.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import json
1212
import uuid
1313

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

25-
from shell_utils import shell_tool_call
26-
from mcp_utils import DEFAULT_MCP_CLIENT_SESSION_TIMEOUT, ReconnectingMCPServerStdio, AsyncDebugMCPServerStdio, MCPNamespaceWrap, mcp_client_params, mcp_system_prompt, StreamableMCPThread
27-
from render_utils import render_model_output, flush_async_output
28-
from env_utils import TmpEnv
29-
from yaml_parser import YamlParser
30-
from agent import TaskAgent
31-
from capi import list_tool_call_models
32-
from available_tools import AvailableTools
25+
from .shell_utils import shell_tool_call
26+
from .mcp_utils import DEFAULT_MCP_CLIENT_SESSION_TIMEOUT, ReconnectingMCPServerStdio, AsyncDebugMCPServerStdio, MCPNamespaceWrap, mcp_client_params, mcp_system_prompt, StreamableMCPThread
27+
from .render_utils import render_model_output, flush_async_output
28+
from .env_utils import TmpEnv
29+
from .yaml_parser import YamlParser
30+
from .agent import TaskAgent
31+
from .capi import list_tool_call_models
32+
from .available_tools import AvailableTools
3333

3434
load_dotenv()
3535

3636
# only model output or help message should go to stdout, everything else goes to log
3737
logging.getLogger('').setLevel(logging.NOTSET)
38+
39+
# Create logs directory if it doesn't exist
40+
# This is needed when running the code as a package from any directory
41+
log_dir = os.path.join(os.getcwd(), 'logs')
42+
os.makedirs(log_dir, exist_ok=True)
43+
3844
log_file_handler = RotatingFileHandler(
39-
'logs/task_agent.log',
45+
os.path.join(log_dir, 'task_agent.log'),
4046
maxBytes=1024*1024*10,
4147
backupCount=10)
4248
log_file_handler.setLevel(os.getenv('TASK_AGENT_LOGLEVEL', default='DEBUG'))

mcp_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from mcp.types import CallToolResult, TextContent
1515
from agents.mcp import MCPServerStdio
1616

17-
from env_utils import swap_env
17+
from .env_utils import swap_env
1818

1919
DEFAULT_MCP_CLIENT_SESSION_TIMEOUT = 120
2020

0 commit comments

Comments
 (0)