Skip to content

Conversation

YuanmingLeee
Copy link
Contributor

@YuanmingLeee YuanmingLeee commented Jul 14, 2025

Implement a refactored Kaggle workflow using LangGraph's functional API, providing a modular design for easier readability and maintenance. Each task is encapsulated as a callable node, streamlining collaboration and functionality swapping.

This change improves flexibility and scalability for managing Kaggle competitions while maintaining seamless orchestration.

Closes #314

Demo

  1. Download dataset
mle bench prepare -c aerial-cactus-identification
  1. Start vLLM Server
vllm serve Qwen/Qwen3-4B-AWQ --enable-auto-tool-choice --tool-call-parser hermes --reasoning-parser deepseek_r1
  1. Run kaggle competition workflow
python ./kaggle_solver.py -c aerial-cactus-identification --model Qwen/Qwen3-4B-AWQ test

Demo logs with vllm+qwen3-4B-AWQ model backend:

Step1 Setup env, collect basic metadata:
image
Step2 Advisory Summary:
image
Step3 Planer:
image
Step4 Code for each planned tasks sequentially
image image image image image image image image image image image ... (nothing to change for the last step) Kaggle workflow completed!

TODO

  • Project setup with a venv (simple sandbox)
  • Coder output to a file
  • Debuger actually run the code, rather than just view it, and collect the debugging logs
  • Add plan: output a submission csv

Before submitting this PR, please make sure you have:

  • confirmed all checks still pass OR confirm CI build passes.
  • verified that any code or assets from external sources are properly credited in comments and/or in
    the credit file.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 14, 2025
@dosubot dosubot bot added the enhancement New feature or request label Jul 14, 2025
Implement a refactored Kaggle workflow using LangGraph's functional API,
providing a modular design for easier readability and maintenance.
Each task is encapsulated as a callable node, streamlining collaboration
and functionality swapping.

This change improves flexibility and scalability for managing Kaggle
competitions while maintaining seamless orchestration.
…nd error handling

- Fix bug: working dir not found for plan and advisor agents
Remove redundant agent initialization and workflow cache logic. Simplify the Kaggle solver pipeline by consolidating agent calls and reducing state dependencies.
@HuaizhengZhang
Copy link
Contributor

Looks good

@HuaizhengZhang
Copy link
Contributor

working dir is all you need 😏

…kflow

Introduce `AdviseAgent`, `PlanAgent`, and `CodeAgent` for simplify tasks prompts and LLM calls in the Kaggle competition pipeline.
Enhance utility functions and setup procedures, such as virtual
environment creation, dataset structure visualization, and compatibility checks.
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 20, 2025
@YuanmingLeee
Copy link
Contributor Author

Previous prompt flows were too complex for integration with vLLM, particularly when involving tool calling.

So I copy and simplified previous agent workflows to exp folder; add some env collection steps for better enforcement with 8B Qwen model (seems like this is the most suitable model for balancing perf and speed with one 4090)

More simplification can be achieved with language graph message passing. 2-3 more days needed for refinement

@HuaizhengZhang
Copy link
Contributor

integration with vLLM, particularly when involving tool calling.

I feel chances.

Refactored `AdviseAgent` and `CodeAgent` to implement agent subgraph calls.

This change improves modularity, simplifies object instantiation, and
enhances maintainability by consolidating logic into reusable components.
- Add utilize `safe_fileio` for secure file I/O within tool handling, and introduced a dependency retrieval method (`deps`) to manage runtime requirements.

Improves code modularity for better aligns with agent processing flows for code generation and execution.
- Refactor `PlanAgent` to decouple environment, simplify initialization, and streamline method logic.
- Add `graph` entrypoint to standardize state-based task processing.
- Improve prompts and golden rules compliance in task execution flows.

Enhances maintainability, enforces single-task focus, and aligns planning logic to agent design. Removes redundant platform details for cleaner environment state.
Introduce `method_task` and `method_entrypoint` decorators to simplify
converting instance methods into reusable langgraph tasks and entrypoints.

This modularizes instance-based task and entrypoint transformation, providing
better code reuse and cleaner abstractions for agents
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jul 23, 2025
@YuanmingLeee
Copy link
Contributor Author

@HuaizhengZhang A workable example using Qwen3-4B, the coding procedure seems neat and minimal. The debugger agent needs to be added to ensure the code is executable without error and produces submission.csv.

Do not review exp/decorators.py; it's for experimental purposes and not yet in effect to simplify the agent code.

- Introduce `verify_code` method to dynamically check and install missing Python dependencies in a virtual environment and execute specified
commands.
- Update `execute_command` function to support additional options for working directory and raw output formatting.
Refactored instance methods to utilize `method_task` and `method_entrypoint` decorators for enhanced readability and encapsulation.
Refactor `method_task` and `method_entrypoint` to streamline their behavior with instance-specific caching and proper binding. Added overloads for cleaner typing and updated implementation for runtime descriptor management.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Exp] Use langgraph for re-implementation of kaggle solver workflow
3 participants