-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feat: Condense Event History #21
Conversation
…handles the same issue
This reverts commit a8befd6.
ece1dc0
to
09fb6e2
Compare
@CodiumAI-Agent /review |
PR Reviewer Guide 🔍
|
@CodiumAI-Agent /ask Give suggestions. |
This comment was marked as spam.
This comment was marked as spam.
@CodiumAI-Agent /ask
It will be handled if new subtypes are introduced. Remember Simple is better than complex.
Both types are strings and remember mypy is happy.
It may not be raised.
Yep, Quoting from Previous PR |
Ask❓
Answer:Missing HandlingThe def parse(self, response) -> Action:
if isinstance(response, AgentSummarizeAction):
return response
# Handle other potential subtypes here
action_str = self.parse_response(response)
return self.parse_action(action_str) This ensures that any new subtypes of String ConcatenationIn the elif isinstance(action, AgentSummarizeAction):
return (
f'Summary of all Action and Observations till now. \n'
f'Action: {str(action.summarized_actions)}\n'
f'Observation: {str(action.summarized_observations)}'
) Error HandlingThe def condense(self, messages: list[Message]):
try:
# Existing condense logic
except SummarizeError as e:
logger.error(f'Condensation failed: {str(e)}')
# Handle the error, e.g., by returning a default action or re-trying with different parameters
return None Token Limit CheckThe def is_over_token_limit(self, messages: list[Message]) -> bool:
"""
Estimates the token count of the given events using litellm tokenizer and returns True if over the max_input_tokens value.
Parameters:
- messages: List of messages to estimate the token count for.
Returns:
- Estimated token count.
Note:
- A padding of 512 tokens is added to account for potential discrepancies in token counting.
"""
MAX_TOKEN_COUNT_PADDING = 512
if not self.config.max_input_tokens:
return False
token_count = self.get_token_count(messages=messages) + MAX_TOKEN_COUNT_PADDING
return token_count >= self.config.max_input_tokens This documentation clarifies the purpose of the padding and helps maintainers understand its necessity. |
@CodiumAI-Agent /ask
Other subtypes of Action are already handled after that. What will be the new subtypes of AgentSummarizeAction? Even if it so, it will be inside the if branch.
f is not needed in first.
need to check why, where, and when it will fail. |
Ask❓
Answer:
The new subtype introduced in this PR is
You are correct. The first return (
'Summary of all Action and Observations till now. \n'
+ 'Action: '
+ action.summarized_actions
+ '\nObservation: '
+ action.summarized_observations
)
To ensure the system remains consistent, it is crucial to handle exceptions that might arise during the summarization process. The
Example of handling these exceptions: try:
response = self.llm.completion(
messages=[message.model_dump() for message in messages],
stop=[
'</execute_ipython>',
'</execute_bash>',
'</execute_browse>',
],
temperature=0.0,
condense=True,
)
except SummarizeError as e:
logger.error(f'Summarization failed: {str(e)}')
# Handle the error, e.g., by notifying the user or taking a fallback action
except ContextWindowLimitExceededError as e:
logger.error(f'Context window limit exceeded: {str(e)}')
# Handle the error, e.g., by notifying the user or taking a fallback action By handling these exceptions, the system can maintain consistency and provide a better user experience even in failure scenarios. |
Applied the suggestions in 7abe952 |
Fix All-Hands-AI#1748
Adding All-Hands-AI#2937.