improvement: switch run_command to process.exec with cwd/env/timeout support#4
Open
hjpinheiro wants to merge 1 commit into
Open
improvement: switch run_command to process.exec with cwd/env/timeout support#4hjpinheiro wants to merge 1 commit into
hjpinheiro wants to merge 1 commit into
Conversation
Replace session-based execution (create_session + execute_session_command
+ delete_session) with a single process.exec() call. This eliminates
per-command session overhead and adds support for:
- cwd: working directory for command execution
- env_vars: environment variables as JSON object string
- timeout: optional execution timeout in seconds
Also adds create_text_message so the agent sees command output directly
in the chat (previously only JSON was returned).
Breaking: output format changes from {stdout, stderr} to {output} (combined).
The process.exec API returns combined stdout+stderr in the result field.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the session-based execution pattern with a single
process.exec()call, adding support for working directory, environment variables, and timeout.What changed
Before (session-based — overhead per command):
After (single call — cleaner, more capable):
New parameters
cwd/home/daytona/project)env_varstimeoutOther improvements
create_text_message(response.result)so agents see command output directly in chat (previously only JSON was returned)_parse_env_vars()helper supporting both JSON strings and dictsThe JSON response changes from separate
stdout/stderrfields to a combinedoutputfield:This is because
process.execreturns combined output inresult. If separate stdout/stderr is important, the session-based approach can be kept as an alternative.Testing
py_compilepassesyaml.safe_load()process.execsignature verified:(command, cwd=None, env=None, timeout=None) -> ExecuteResponse