agent_executor.invoke method: An error occurred: Invalid control character at: line y column xxx (char xxx)
Labels: name: area: agent, name: auto:bug

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.

### Example Code

Here is my custom parser code:

```
def parse(output):
    

    # If no function was invoked, return to user
    if "function_call" not in output.additional_kwargs:
        return AgentFinish(return_values={"answer": output.content, "sources":""}, log=output.content)
    
    # Parse out the function call
    function_call = output.additional_kwargs["function_call"]
    name = function_call["name"]
    inputs = json.loads(function_call["arguments"])

    # If the Response function was invoked, return to the user with the function inputs
    if name == "Response":
        return AgentFinish(return_values=inputs, log=str(function_call))
    # Otherwise, return an agent action
    else:
        return AgentActionMessageLog(
            tool=name, tool_input=inputs, log="", message_log=[output]
        )
```

Here is my agent code:

```
agent = (
                                          {
                                              "input": itemgetter("input"),
                                              # Format agent scratchpad from intermediate steps
                                              "agent_scratchpad": lambda x: format_to_openai_functions(
                                                  x["intermediate_steps"]),
                                              "history" : lambda x:x["history"]
                                          }
                                          | prompt
                                          | condense_prompt
                                          | llm_with_tools
                                          | parse
                                      )

 
                    agent_executor = AgentExecutor(tools=[retriever_tool], 
                                                   agent=agent,
                                                   memory=st.session_state.agentmemory,
                                                   verbose=True, 
                                                   handle_parsing_errors=True,
                                                   )
```

### Description

I get the following error when I call my agent_executor.invoke method - An error occurred: Invalid control character at: line 2 column 129 (char 130) - This is only when my retriever returns some special characters such as " • " - I'm assuming it is this - a bullet point dots.

I have been using a custom parser:  How can I use the solution from below link for output parser solution to solve the problem with a custom parser? Or add "strict=False" in the json response?

Or is there any other solution?

https://github.com/langchain-ai/langchain/issues/9460

### System Info

langchain==0.0.315
pydantic==2.5.2
streamlit==1.29.0
openai==0.28

### Related Components

- [X] LLMs/Chat Models
- [X] Embedding Models
- [X] Prompts / Prompt Templates / Prompt Selectors
- [X] Output Parsers
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [X] Memory
- [X] Agents / Agent Executors
- [X] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async