From 631b2c44d8a348d2bd0cfc12e451e954341883d2 Mon Sep 17 00:00:00 2001 From: Farouk Adeleke Date: Sun, 9 Nov 2025 05:04:24 -0500 Subject: [PATCH] add thread id property --- README.md | 3 --- config.json | 6 +++--- main.py | 2 +- src/index.py | 20 ++++++++++++++++---- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index bead005..3ce04aa 100644 --- a/README.md +++ b/README.md @@ -57,9 +57,6 @@ def main(): "darinkishore/codex-agent", config_options={ "signature": sig, - "working_directory": ".", - "model": "gpt-4o", - "codex_path_override": "/opt/homebrew/bin/codex" # Optional: customize codex binary path }, ) diff --git a/config.json b/config.json index 39bcb01..97a9002 100644 --- a/config.json +++ b/config.json @@ -1,10 +1,10 @@ { "signature": "message:str -> answer:str", - "working_directory": "", - "model": null, + "working_directory": ".", + "model": "gpt-4o", "sandbox_mode": null, "skip_git_repo_check": false, "api_key": null, "base_url": null, - "codex_path_override": null + "codex_path_override": "/opt/homebrew/bin/codex" } \ No newline at end of file diff --git a/main.py b/main.py index d85f1ab..b66b97b 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ codex_agent = CodexAgent(CodexAgentConfig()) def main(): - codex_agent.push_to_hub("darinkishore/codex-agent", with_code=True, commit_message="update README.md") + codex_agent.push_to_hub("darinkishore/codex-agent", with_code=True, commit_message="add thread id property") #result = codex_agent(message="What files are in this directory?") #print(result.answer) # String response #print(result.trace) # Execution items (commands, files, etc.) diff --git a/src/index.py b/src/index.py index 237002f..62294fe 100644 --- a/src/index.py +++ b/src/index.py @@ -8,13 +8,13 @@ from typing import Optional class CodexAgentConfig(PrecompiledConfig): signature: str | type[Signature] = "message:str -> answer:str" - working_directory: str = "" - model: Optional[str] = None + working_directory: str = "." + model: Optional[str] = "gpt-4o" sandbox_mode: Optional[SandboxMode] = None skip_git_repo_check: bool = False api_key: Optional[str] = None base_url: Optional[str] = None - codex_path_override: Optional[str] = None + codex_path_override: Optional[str] = "/opt/homebrew/bin/codex" class CodexAgent(PrecompiledAgent): config : CodexAgentConfig @@ -34,4 +34,16 @@ class CodexAgent(PrecompiledAgent): ) def forward(self, **kwargs) -> Prediction: - return self.codex_module(**kwargs) \ No newline at end of file + return self.codex_module(**kwargs) + + @property + def thread_id(self) -> Optional[str]: + """Get thread ID for this agent instance. + + The thread ID is assigned after the first forward() call. + Useful for debugging and visibility into the conversation state. + + Returns: + Thread ID string, or None if no forward() calls have been made yet + """ + return self.codex_module.thread.id \ No newline at end of file