-
Notifications
You must be signed in to change notification settings - Fork 8.2k
[refactor]: call load_openhands_config in resolver #8641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[refactor]: call load_openhands_config in resolver #8641
Conversation
Hey @kotauchisunsun ! Just to understand where we're heading: IMHO in the future we should not construct At least, that's my thought about the way forward here. What do you think of this goal? Do you think this refactoring is heading there or do you have a different take? |
|
@enyst However, I'm currently facing several issues around this and am unsure about the best solution. The main problem is that I'm considering whether this should be replaced with I'm starting to think that if we do override However, doing so would require generating workspace_base inside resolve_issue.py, which is currently handled in The problem is that generating workspace_base depends on both issue_handler and the issue, which makes things a bit tricky. That leads me to wonder whether it makes sense to add Do you have any suggestions or thoughts on a clean way to resolve this? That's why I've been working on refactoring and breaking things up incrementally—hoping that by reducing visible complexity (like class variables), a clearer solution will eventually emerge. |
|
A few thoughts, please do let me know if I'm missing something.
I hear you, we even used to have an unwritten rule that the config attributes were not overridden from outside So we have a choice here, do it somewhere in the resolver, for the resolver overrides, or make sure to do it only in The second option is to have a standard way to do overrides from various entry points (such as a resolver override method in Or maybe we can do 1), as long as we're doing it all in a single place. So that we can refactor it later easily and move to 2).
Please correct me if I'm not seeing this right, it seems to me that it depends only on things we have in the Thank you for the discussion and the work on this! It's so important to get it cleaned up, so that we reduce risks of the code fragility and maybe be able to move forward easier. |
Yeah, that often happens as development progresses. Software development is hard. 😅
I also think option 1 is fine, at least for now. As long as we avoid scattering the config initialization logic, I believe it's acceptable.
You're right that both issue and issue_handler can be injected at construction time. However, there’s a part of the logic in resolve_issue that uses issue_handler to build the issue: If we decide to inject AppConfig into the constructor, this part would also need to be moved into resolve_issue.py. Personally, I like this kind of change. But I also realize that since it touches a lot of areas, others might feel differently or have concerns about the size of the change. There's also one more point I forgot to mention — the dependency on the workspace path. So, if we were to move the workspace_base logic into resolve_issue.py, that would effectively split the definition of the workspace path across two places — resolve_issue.py and IssueResolver — which could lead to future confusion. For example, if someone changes the workspace path in resolve_issue but not in IssueResolver, or vice versa, it might cause subtle bugs. That’s why I was thinking that if we go down that route, we should also refactor things to unify the handling of the workspace path, potentially by moving it to a shared class-level variable. But of course, that would expand the scope of the change quite a bit. 😅 |
|
Thank you! OK, I think I follow, although please note that I'm not at the computer right now, so just from github: Re: we could get the final
Re: Re: |
|
Glad we could have this discussion. I now understand that we’ll need to approach this in stages, and that we probably don’t need to worry too much about the workspace path for now. With that in mind, how should we modify this PR in the end? |
|
Maybe we could go the other way around than this PR is doing: instead of taking This depends on us not writing to config classes (or creating config classes) anywhere else in the resolver code. Not sure if we're there yet? |
…a class attribute
a0eb443 to
26b428a
Compare
|
I performed a step-by-step refactoring. I attempted to move the initialization of AppConfig into the constructor. This issue doesn’t affect the existing test for resolve_issue in github/test_resolver.py. There are a few possible solutions. First, the fundamental question is whether or not we should move the initialization of AppConfig into the constructor in this PR. If we consider moving the AppConfig initialization into the constructor, there are two options:
If we consider injecting AppConfig into the constructor instead:
I believe mocking issue_handler in tests is necessary, but it seems like it would require a significant amount of change to the test code. When I previously suggested passing issue as an argument to resolve_issue, this context was also part of my thinking. This ultimately may come down to a matter of design taste and the desire to keep this PR small and manageable. How should we proceed with the changes in this PR? |
|
How about, in IssueResolver.init(), something like (pseudocode) Maybe that's missing some complexity? It seems that issue_type is here, issue_number is here. Please feel free to shut it down if wrong! |
… clarity and consistency
…attribute for improved consistency
…s for improved flexibility
…and sandbox_config for improved flexibility
…improved configurability
…emove redundant LLMConfig setup
…parameter and update sandbox configuration handling for improved clarity and maintainability
8c0ed36 to
935a50c
Compare
…idating config loading and sandbox updates for improved clarity and maintainability
…ntroducing SandboxConfig initialization and updating the configuration assignment process for improved clarity and maintainability
enyst
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is shaping up great!
|
What do you think, @kotauchisunsun , is it ready to merge or close to? I looked at every commit, and you did the refactoring step by step carefully, and it looks safe to me, unlikely to break things. Also, the tests pass. |
|
@enyst I’ve confirmed the runtime behavior locally using the following command, and all tests pass: I also verified the behavior in my own sample repository: Here is the execution log: By adding the fix-me-experimental label, I was able to check out and run this branch: The pull request was successfully created: |
|
OK, thank you! I really really appreciate this work, @kotauchisunsun , it's something I think we've been missing for quite a while now. ❤️ The changes in this PR are around loading and overriding the app configuration. For a bit of history, the resolver used to be developed as an external script, it initialized itself first and then loaded Cc: @malhotra5 @neubig |
…r and move sandbox setup to a dedicated function
End-user friendly description of the problem this fixes or functionality this introduces.
Summarize what the PR does, explaining any non-trivial design decisions.
To decouple the command-line parsing logic from the processing logic, I’ve refactored
setup_sandbox_configfrom a class method into a standalone function.To keep the diff manageable, I’m temporarily passing both
argsandsandbox_configto theIssueResolverconstructor. In a future update, the constructor will no longer depend onargs, and the necessary values will be passed as individual variables instead.Link of any specific issues this addresses:
#8516
#8619